mdbook-version: 'latest'
- name: Get becnhmarks
- run: git submodule update --init gwion-benchmark
+ run: |
+ git submodule update --init gwion-benchmark
+ cd benchmark
+ git pull
- name: Build book
run: |
# Keywords
- * fun/function
+ * fun
* operator
* return
* goto
* typeof
* typedef
+ * funcdef
* class
* dtor
* extends
Declaring a primitive or an object is quite straight forward:
@``` decl0.gw
-int i;
-Object o;
+var int i;
+var Object o;
<<< i, " ", o >>>;
@```
@hide make -s decl0.test
## Declaring a reference
@``` decl1.gw
-Object ref object_ref;
+ref Object object_ref;
<<< "Reference points to no object yet: ", object_ref >>>;
new Object @=> object_ref;
<<< "But now it does: ", object_ref >>>;
### array as refs
@``` decl2.gw
-int array_ref[];
+var int array_ref[];
<<< array_ref >>>;
new int[2] @=> array_ref;
<<< array_ref >>>;
## basic loops
@``` forloop0.gw
-for(int i; i < 3; ++i)
+for(var int i; i < 3; ++i)
<<< i >>>;
@```
@hide make -s forloop0.test
It also works with a block of code.
@``` forloop2.gw
-for(int i; i < 3; ++i) {
+for(var int i; i < 3; ++i) {
i/2 => float f1;
i/2. => float f2;
<<< i, " " , f1, " ", f2 >>>;
@``` forloop3.gw
int array[3][4];
-for(int i; i < 3; ++i) {
- for(int j; j < 4; ++j) {
+for(var int i; i < 3; ++i) {
+ for(var int j; j < 4; ++j) {
<<< array[i][j] >>>;
}
}
#### Simple auto loop
@``` forloop4.gw
-int array[2][3];
+var int array[2][3];
foreach(a: array) {
<<< a >>>;
foreach(b: a)
If you want to change it the value in the array, you need a pointer
@``` forloop5.gw
-int array[2][3];
-int i;
+var int array[2][3];
+var int i;
foreach(a: array) {
foreach(ref b: a)
<<< ++i => *b >>>;
@``` repeat2.gw
repeat(3) {
- maybe ? "You" : "Me" => string s;
+ maybe ? "You" : "Me" => var string s;
<<< "Hello, ", s, "!" >>>;
}
@```
### Passing to a function pointer
@``` lambda_fptr0.gw
typedef void fptr_t(int);
-\ i { <<< "passed '", i, "'" >>>; } @=> fptr_t fptr;
+\ i { <<< "passed '", i, "'" >>>; } @=> var fptr_t fptr;
fptr(4);
@```
@hide make -s CONTAINS="passed '4'" lambda_fptr0.test