http://Ya-Lang.com . Designed and made by Pavel Senatorov, see Ya-Lang.com for emailing.
Ya is based on CeePlusPlus (C++) and gets most of C++ as is. Yet there is no compatibility with C++, C++ program is not a Ya program and cannot be compiled as is. Anyway it's
Main news in comparison with C++:
Appeared at 2012.
Works only in Windows for now.
== Example: Hello World ==
@HelloWorld.Ya;
using
printf("Hello, %s!\n", args.Length > 1 ? args[1] : "World");
return 0;
== Basics of Ya ==
=== Block structure is described by tabs at starts of lines ===
Tabs at start of line are counted and used for specifying code blocks {...}
, like in [[Python]]. But blocks made in single line with {
and }
are also supported. Typical Ya program has near to no one {
and }
.
=== Modules, ala #define and no project file ===
@
FileName; at the start of each compiled file. Modules are always named starting by @
and module name is module's file name. Example: @C:/S/Ya/YaParser.Ya;
using @module, @module;
so separate header and implementation for a module does not used, because using @module;
gets interface of module into work but not implementation details.
using @module, @module;
so that all required modules will be included and compiled. As a result a separate project file is not required.
=== Double compilation aka [[Metaprogramming]] ===
=== Extensible syntax ===
foreach
for newly written type of a container.
=== Extensible lexical tokens ===
<=>
, which makes such kind of comparison.
<->
will notify exchange of values of variables (swap). Usage: $int i,j; i <-> j;
10:53:17
- addition of a new kind of constant is described as [[regex|regular expression]] and the code for transforming of text of new constant into required type the programmer writes on Ya. Note that this code will be executed at compile time, not run time. So this feature requires what they name [[metaprogramming|double compilation]]. Making new constants not yet ready.
=== Support for databases and internal structures like databases ===
It will probably be done as library. It will be possible to write expression that works with a number of tables, which are sets (f.e. arrays, lists) of fielded type (of class), and perform join where sortby
of SQL. In C# it is named [[Language Integrated Query]].
=== Multiple names for any entity is allowed ===
Variables, functions, types and template argument requirements all may be named by a number of names. No need to use #define
instead. Example: $int a b c = 100;
- here you can use this variable by name a
or b
or c
.
=== Description of types ===
$
and type name must go after $
without spaces - it's a single token.
*
are written without spaces also.
$int
.
!any $constint = $int-; !any $
PtrToInt = $int*;
class
is not used. Instead you just write !any $myClass { body of structure-class }
$int+-*-
means in C++ const unsigned int* const
, here +
means unsigned
and -
means const
.
&
, only pointers *
are used. References in C++ is a side-effect feature and is of value only because no need to write * to dereference a reference. But the same is with pointers in Ya, even more, see below.
const unsigned signed
all have gone.
$int**
, then you write $int** A, B, C;
instead of int **A, **B, **C;
. Description becomes shorter, yet there is no way to define int A, *B;
in 1 statement, 2 statements are required: $int A; $int* B;
.
=== Many small changes in the base of C++ ===
$int** ptrptr; $int i = ptrptr;
- here in i = ptrptr;
is automatic double dereferencing a pointer.
$T* $T* a = $T* b;
specifies assignment for type $T
. Both args and return type are specified as pointers - this is because there are no references and because working with pointers is simple, no need to dereference or getting address, all this is automatically inserted.
!
SomeName, for example !any
in type definitions above means that specified type has no requirements. Example of requirements definition: #template != { $* $* a = $* b; }
specifies that !=
types must have assignment operation $* $* a = $* b;
for
statement: for
InitExprOrVarDef; ConditionExpr; IncExpr { BodyOfLoop } - so 1.parenceses not used, 2.body of loop is always in {} - typically it means that body of loop is on next lines and is 1 tab right shifted. All other is the same as in C++. if while do while switch
are all the same - everywhere no () and body of statement is block.
switch
statement example:
printf("Wow! It's 0,1,2,3 or 7\n");
5
printf("Simple case!\n");
else
printf("default is written as default or else.\n"); }}
- each case starts without case
and :
after case values is not written. Case values can include many values and also ranges value..value
, like in 0..3,7
- this case works if switched with 0,1,2,3 or 7. Also no need to write break;
to break out of case - it is automatically included at the end of a case. But if it's required to continue on next case then continue;
may be used - it jumps to the body of next case.
break;
- breaking from loops and switches is enchanced, it is possible to break from many loops+switches in 1 step. Example: for ;; { for ;; { switch 7 { 0..3,7 { break for for switch; }}}}
1+2 * 3;
- it's (1+2) * 3;
because no spaces in 1+2
and 1 space in 2 *
enum
is extended: they are not only int
but of any type, the type is specified. Example:
Str1 = "lala", Str2 = "bebe"
!any $ErraType enum $int+:8 // i.e. they are unsigned bytes
eFatal, eErr, eWarn, eMess,