There are the usual flow-of-control statements:
There are the usual flow-of-control statements:
An expression on a line by itself also constitutes a statement:
Assignment in Trylon is designed to be easy to read (and type), but the rules behind it can be a little complex.
The basic idea is that an assignment will assign to a variable in the current scope, and if no such variable exists, a new local variable will be created. The scope of the new local is the block in which it is assigned.
Assignment can also be a shorthand for a function call:
If the function being set is a unary function, rather than a keyword function, then the setter function's name is the unary function's name with a colon appended:
(Indeed, the compiler treats *all* assignments this way, even those to local variables. So "foo = bar" can always be written as "foo: bar".)
Assignments are expressions, so you can do things like "x = y = 0".
A "for" statement can iterate over any collection that responds to the "iterate" message with an iterator object that responds to the "is-done", "current-item", and "go-forward" messages. So this:
is roughly equivalent to this:
(I say "roughly" because the "continue" statement would work correctly in a real "for" loop, and because the "iterator" variable isn't visible.)
The "iff" statement is used for conditional compilation:
In this case, "debug" is not an expression, but the name of a symbol. If that symbol is defined in the build-settings, the block will be compiled. If not (or if it's set to "false"), the block will be completely ignored by the compiler.
You can't use an "else" block with an "iff" statement (not yet, anyway), but you can put a "!" before the symbol to reverse the sense of the test.
A few symbols are defined automatically in the build-settings. Most notably, the "sysname" (what you'd see if you typed "uname" at the shell) is defined.
Also defined are "trylon-2" (to distinguish from Trylon 1; Trylon 3 also defines it), and "targeting-c" to distinguish the C backend from the other backends (like the now-deleted Jolt backend, or any future backends).