Code by Zed Lopez
You always need whitespace between operators and operands.
Local variable creation
With the kind name and var:
number var x;
Immediate assignment with the kind name and var:
number var x = 5;
But if you're making an assignment, you don't need to specify the kind:
var x = 5;
Well, almost never. With a topic you'd need:
topic var t = "donuts";
because just
var t = "donuts";
would result in t being a text variable.
Assignment with =
let t be a text; let L be a list of numbers; let n be 12;
t = "cat"; L = { 2, 4 }; n = 5;
A ternary operator
i = (j > 1)? j # k;
Comparison with ==, <>,! =
let s be "cat"; if t == s, say "meow"; if L == { 2, 4 }, say "unchanged";
With texts, this is equivalent to if t exactly matches the text s (i.e., *not* if t is s).
You can also test not-equal with your choice of <> or! =. I'm not one to judge.
Attribute accessor
Instead of <property name p> of <object o> you can just use:
o ~> p.
Arithmetic assignment operators:
n += 1; x -= 2; i /= 3; j *= 4;
They don't return a value and can't be used in conditionals.
Increment/decrement operators for numbers in conditionals:
if (n ++) unless (-- i)
They don't work outside of conditionals; use += or -= for imperative phrases.
Bit operators
Not:
l = ~ m;
XOR:
m = n ^ o;
AND:
i = j & k;
OR:
k = l | m;
Shift left:
b = c << 1;
Shift right:
f = g >> 2;
All of the above have assignment variants, too:
b <<= 1; m |= n;
Truthiness and Falsiness
Truth states, numbers, and texts are conditionals unto themselves. With numbers, 0 is considered false; with texts, the empty string is considered false.
Regexp operators
Matches:
t = "banana"; t ~= / "((na)+)" /; n = $1;
The whole matched text is in $0; the first 9 subexpressions are in $1 to $9.
In a conditional, the opening slash must be preceded by ``m``:
if t ~= m/ "xyzzy" /
And substitutions:
t =~ s/ "na" / "X" /; t =~ s/ "na" / "X" /g;