```cpp
// print hello world
-<<<"Hello World">>>;
+<<< "Hello World" >>>;
```
to run this, do
-Subproject commit 879a632ed9372315428c562077f2b8a811ec74dc
+Subproject commit 6860cd22ad558e5efa3bb183fa71bf3c10bc80a7
@``` decl0.gw
int i;
Object o;
-<<<i, " ", o>>>;
+<<< i, " ", o >>>;
@```
@exec gwion decl0.gw 2>&1
However ...
@``` decl1.gw
Object @ref;
-<<<"Reference points to no object yet: ", ref>>>;
+<<< "Reference points to no object yet: ", ref >>>;
//Object o @=> ref;
new Object @=> ref;
-<<<"But now it does: ", ref>>>;
+<<< "But now it does: ", ref >>>;
@```
@exec make decl1.test
@``` decl2.gw
int ref[];
-<<<ref>>>;
+<<< ref >>>;
new int[2] @=> ref;
-<<<ref>>>;
+<<< ref >>>;
@```
@exec make decl2.test
You can even use it to
### Call a function just once
@``` lambda_call0.gw
-\ i { <<<"passed '", i, "'">>>; }(3);
+\ i { <<< "passed '", i, "'" >>>; }(3);
@```
@exec make -s CONTAINS="passed '3'" lambda_call0.test
### Passing to a function pointer
@``` lambda_fptr0.gw
typedef void fptr_t(int);
-\ i { <<<"passed '", i, "'">>>; } @=> fptr_t fptr;
+\ i { <<< "passed '", i, "'" >>>; } @=> fptr_t fptr;
fptr(4);
@```
@exec make -s CONTAINS="passed '4'" lambda_fptr0.test
fun void test(fptr_t fptr) {
fptr(5);
}
-test(\ i { <<<"passed '", i, "'">>>; });
+test(\ i { <<< "passed '", i, "'" >>>; });
@```
@exec make -s CONTAINS="passed '5'" lambda_args0.test
## a simple example
@``` variadic.gw
fun void variadic_test(int i, ...) {
- <<< "first argument is ", i >>>;
+ <<< "first argument is ", i >>>;
vararg.start;
- <<< "\tadditionnal argument", vararg.i >>>;
+ <<< "\tadditionnal argument", vararg.i >>>;
vararg.end;
}
variadic_test(1);
}
// now call the function (and debug print the result)
-<<<test_function(0)>>>;
+<<< test_function(0) >>>;
// or use alternate syntax
-<<<1 => test_function>>>;
+<<< 1 => test_function >>>;
@```
@exec make -s function0.test
## Very basic example
@``` repeat.gw
repeat(3)
- <<<"Hello, world!">>>;
+ <<< "Hello, world!" >>>;
@```
@exec make -s CONTAINS="Hello" repeat.test
@``` repeat2.gw
repeat(3) {
maybe ? "You" : "Me" => string s;
- <<<"Hello, ", s, "!">>>;
+ <<< "Hello, ", s, "!" >>>;
}
@```
@exec make -s CONTAINS="Hello" repeat2.test
## basic loops
@``` forloop0.gw
for(int i; i < 3; ++i)
- <<<i>>>;
+ <<< i >>>;
@```
@exec make -s forloop0.test
for(int i; i < 3; ++i) {
i/2 => float f1;
i/2. => float f2;
- <<<i, " " , f1, " ", f2>>>;
+ <<< i, " " , f1, " ", f2 >>>;
}
@```
@exec make -s forloop2.test
for(int i; i < 3; ++i) {
for(int j; j < 4; ++j) {
- <<<array[i][j]>>>;
+ <<< array[i][j] >>>;
}
}
@```
@``` forloop4.gw
int array[2][3];
for(auto a: array) {
- <<<a>>>;
+ <<< a >>>;
for(auto b: a)
- <<<b>>>;
+ <<< b >>>;
}
@```
@exec make -s forloop4.test
int i;
for(auto a: array) {
for(auto @b: a)
- <<<++i => *b>>>;
+ <<< ++i => *b >>>;
}
for(auto a: array) {
for(auto @b: a)
- <<<*b>>>;
+ <<< *b >>>;
}
@```
@exec make -s forloop5.test
while(true) {
if(maybe)
break;
- <<<"running...">>>;
+ <<< "running..." >>>;
}
@```
@exec make -s while0.test
lets try
@``` while1.gw
-<<<maybe>>>;
+<<< maybe >>>;
do{
if(maybe)
break;
- <<<"running...">>>;
+ <<< "running..." >>>;
} while(true);
@```
@exec make -s while1.test
for:
@``` helloworld.gw
-<<<"Hello, World!", "">>>;
+<<< "Hello, World!", "" >>>;
@```
@exec make -s CONTAINS="Hello, World!" helloworld.test