
| Official website |
|---|
| Execution method: | Compiled (machine code) |
|---|---|
| Garbage collected: | No |
| Parameter passing methods: | By reference, By value |
| Type safety: | Safe, Unsafe |
| Type strength: | Strong |
| Type compatibility: | Nominative, Structural |
| Type expression: | Explicit |
| Type checking: | Dynamic, Static |
| Lang tag(s): | Ya |
| See Also: |
Ya (pronounced /jˈʌ/) is based onC++ and gets most ofC++ as is. Yet there is no compatibility withC++,C++ program is not aYa program and cannot be compiled as is.
Ya adds toC++ extensible syntax, extensible lexical tokens, possibility to execute parts of compiling program during it's compilation (metaprogramming), support forSQL-like operations for processing databases and database-like internal data, and many small improvements overC++.
@HelloWorld.Ya;using <stdio.h>;$int($char[][] args) mainprintf("Hello, %s!\n", args.Length > 1 ? args[1] : "World");return 0;
Tabs at start of line are counted and used for specifying code blocks{...}, like inPython. But blocks made insingle line with{ and} are also supported. Typical Ya program has near to no one{ and}.
@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, becauseusing @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.foreach for newly written type of a container.<=>, 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 asregular 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 namedouble compilation. Making new constants not yet ready.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 performjoin where sortby of SQL. In C# it is namedLanguage Integrated Query.
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 namea orb orc.
$ 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+ meansunsigned and- meansconst.&, 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 ofint **A, **B, **C;. Description becomes shorter, yet there is no way to defineint A, *B; in 1 statement, 2 statements are required:$int A; $int* B;.$int** ptrptr; $int i = ptrptr; - here ini = 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 operator$* $* 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:switch10-50..3,7printf("Wow! It's 0,1,2,3 or 7\n");5printf("Simple case!\n");elseprintf("default is written as default or else.\n");
Each case starts withoutcase and: after case values is not written. Case values can include many values and also rangesvalue..value, like in0..3,7 - this case works for 0,1,2,3 or 7. Also no need to writebreak; 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 thencontinue; 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 in1+2 and 1 space in2 *enum is extended: they are not onlyint but of any type, the type is specified. Example:!any$StringEnumenum$char[]Str1="lala",Str2="bebe"!any$ErraTypeenum$int+:8// i.e. they are unsigned byteseFatal,eErr,eWarn,eMess,