Wee uses 26 English reserved keywords:
if, is, in, or, go, do use, new, let, get, put, say, def, out, log case, spin, more, node, else, done, back, share, clear run, loop, over
To find public members in other files: Wee create this statement: use folder.name/file_name.wee ... Public members start with capital letter.
out ;write something to console say ;write something to console and new line ask ;print something and wait for input
Wee is typeless, or more precisely has one data type: the computer word. Sometimes this represent a computer address that has to be dereferenced. Capacity of word is 16 bit, 32 bit or 64 bit depending on the operating system. syntax
new identifier : constant ; using constant literal new identifier : expression ; using expression ** define several identifiers with same initial value new identifier, identifier,... :expression example new v : 0 new x,y,z : 10
Expressions can be used for assign operator : or modifiers: +:, -:
new v : 10 ;number new s : 5 ;number let v +: 1 ;make v = 11 let v -: 1 ;make v = 10 let s : v + s; copy v = 15 to s
Wee is using pointers. You can dereference a pointer using symbol "@"
new v : 10 ; define a new variable new p : @v ; define a reference to v say p ; expected 10 ** using assign ":" let v : 2; change underline value of p say ?p ; expected 2 ** reset pointer new o : 4 let p : @o ; reset say p ; expected 4 say v ; expected 2 (unmodified)
The console application accept and print characters:
ask i : "enter any char" say i ; will print the char
Conditional if statement has a postfix form:
statement if condition
let new_variable : (value if condition, value if condition, value);
when condition do ** true else ** false done
case condition do ** first path ... case condition do ** second path ... else ** alternative path ... done
**repetitive block do ... loop if (condition) ... stop if (condition) more
node name: do get a, b, c : 0 put a + b + c done
share new r : 0 put a : 5, b : 10, c : 20 run node_name pop r say r clear
Using outer variables is possible in private context.
new r: 0 share put a: 5, b: 10, c: 20 run node_name pop r clear -- a, b, c say r -- a+b+c = 35
Read next: Collections