+++ /dev/null
-# Control Flow
-
-## Repeats
-let start simple ;-)
+++ /dev/null
-# the Repeat keyword
-let start simple ;-)
-The easiest way to do an action repeatidly in Gwion is, ... the **repeat** keyword!
-
-## Very basic example
-@``` repeat.gw
-repeat(3)
- <<<"Hello, world!">>>;
-@```
-@exec make -s CONTAINS="Hello" repeat.test
-
-## Block example
-of course this also works with a block code.
-
-@``` repeat2.gw
-repeat(3) {
- maybe ? "You" : "Me" => string s;
- <<<"Hello, ", s, "!">>>;
-}
-@```
-@exec make -s CONTAINS="Hello" repeat2.test
+++ /dev/null
-# For Loops
-**For** loops in Gwion is pretty similar to classic **C** syntax
-
-## basic loops
-@``` forloop0.gw
-for(int i; i < 3; ++i)
- <<<i>>>;
-@```
-@exec make -s forloop0.test
-
-Of course, it also works with a block of code.
-
-@``` forloop2.gw
-for(int i; i < 3; ++i) {
- i/2 => float f1;
- i/2. => float f2;
- <<<i, " " , f1, " ", f2>>>;
-}
-@```
-@exec make -s forloop2.test
-
-## Nested Loops
-@``` forloop3.gw
-int array[3][4];
-
-for(int i; i < 3; ++i) {
- for(int j; j < 4; ++j) {
- <<<array[i][j]>>>;
- }
-}
-@```
-@exec make -s forloop3.test
-
-### Auto Loops
-
-#### Simple auto loop
-@``` forloop4.gw
-int array[2][3];
-for(auto a: array) {
- <<<a>>>;
- for(auto b: a)
- <<<b>>>;
-}
-@```
-@exec make -s forloop4.test
-
-### Auto Pointer loop
-With the simple auto loop, you only get the value in the array.
-If you want to change it, you need a pointer
-
-@``` forloop5.gw
-int array[2][3];
-int i;
-for(auto a: array) {
- for(auto @b: a)
- <<<++i => *b>>>;
-}
-for(auto a: array) {
- for(auto @b: a)
- <<<*b>>>;
-}
-@```
-@exec make -s forloop5.test
+++ /dev/null
-# Loops
-
-@``` while0.gw
-while(true) {
- if(maybe)
- break;
- <<<"running...">>>;
-}
-@```
-@exec make -s while0.test
-
-well this may output nothing...
-lets try
-
-@``` while1.gw
-<<<maybe>>>;
-do{
- if(maybe)
- break;
- <<<"running...">>>;
-} while(true);
-@```
-@exec make -s while1.test
+++ /dev/null
-# Giving gwion a new driver
-
-## basics
-
-> in order to use GWION_CTL ...
-
-# concept
-
-# upd driver
+++ /dev/null
-# Writing a Gwion plugin
-
-> THIS IS OUTDATED. please look at the source code in src/lib/ instead
-
- * [getting started]
-
-## Getting started
-use the script
-
-### headers
-```
-#include "vm.h"
-#include "instr.h"
-#include "import.h
-```
-<!-- TODO: verify this -->
-
-### Class
-Define the type:
-```
-struct Type_ t_mytype = { "MyType", SZ_INT, &t_object};
-```
-> every type extending t_object should have SZ_INT
-
-### Handling Constructors and Destructors
-#### CTOR
-```
-CTOR(mytype_ctor) {
- /* constructor code here */
-}
-```
-#### DTOR
-```
-DTOR(mytype_dtor) {
- /* destructor code here */
-}
-```
-
-those macros provide two variables:
- * `o`: the *M_Object* for the (con/des)tructor
- * `shred`: the *VM_Shred* for the (con/des)tructor
-
-```
-CHECK_BB(import_class_begin(env, &t_mytpe, env->global_nspc, mytype_ctor, mytype_dtor))
-```
-#### variable
-declare a `m_int`. coding convention require
- * a leading *_o*
- * a following *_type_*
-```c
-m_int o_mytype_myvaroffset;
-```
-#### function
-```c
-/* declare a member function */
-MFUN(mytype_memberfunction) {
- /* code here */
-}
-
-SFUN(mtype_staticfunction) {
- /* code here */
-}
-```
-
-#### operator
-
-### Import function
-
+++ /dev/null
-# Lambda
-
-## Overview
-
-Simply put, *lambda*s are anonymous functions.
-
-The syntax to create them is simple:
-```
-\ variable0 variable1 ... { your code here }
-```
-You can even use it to
-### Call a function just once
-@``` lambda_call0.gw
-\ i { <<<"passed '", i, "'">>>; }(3);
-@```
-@exec make -s CONTAINS="passed '3'" lambda_call0.test
-
-
-## Use case
-
-### Passing to a function pointer
-@``` lambda_fptr0.gw
-typedef void fptr_t(int);
-\ i { <<<"passed '", i, "'">>>; } @=> fptr_t fptr;
-fptr(4);
-@```
-@exec make -s CONTAINS="passed '4'" lambda_fptr0.test
-
-### As Argument to Functions
-@``` lambda_args0.gw
-typedef void fptr_t(int);
-fun void test(fptr_t fptr) {
- fptr(5);
-}
-test(\ i { <<<"passed '", i, "'">>>; });
-@```
-@exec make -s CONTAINS="passed '5'" lambda_args0.test
+++ /dev/null
-# Variadic functions
-
-> A function whoses arity is not fixed.
-
-Well, a function that takes a fixed number of arguments, and additionnal ones.
-
-## a simple example
-@``` variadic.gw
-fun void variadic_test(int i, ...) {
- <<< "first argument is ", i >>>;
- vararg.start;
- <<< "\tadditionnal argument", vararg.i >>>;
- vararg.end;
-}
-variadic_test(1);
-variadic_test(1, 2);
-variadic_test(1, 2, 3);
-@```
+++ /dev/null
-# Functions
-
-## a simple (commented example)
-
-@``` function0.gw
-// declare function 'test_function'
-// with return type int
-// taking an int as argument
-fun int test_function(int arg) {
- // return the argument + 2
- return arg + 2;
-}
-
-// now call the function (and debug print the result)
-<<<test_function(0)>>>;
-// or use alternate syntax
-<<<1 => test_function>>>;
-@```
-@exec make -s function0.test
-gwion 0.18500 0.63
-wren 0.228810 0.24
-lua 0.31364 1.10
+gwion 0.18650 0.58
+wren 0.23149 1.00
+lua 0.30273 1.31
-gwion 5.2990 0.37
-wren 13.4991 0.34
-lua 7.3146 0.29
+gwion 5.2823 0.38
+wren 13.4943 0.44
+lua 7.3512 0.89
-gwion 0.085201 0.50
-wren 0.210157 0.14
-lua 0.207941 0.43
+gwion 0.084083 0.72
+wren 0.210827 0.32
+lua 0.209405 0.47
-gwion 0.091161 0.26
-wren 0.107611 0.38
-lua 0.25866 1.21
+gwion 0.09491 1.85
+wren 0.11345 5.40
+lua 0.25868 1.48