Conditional compilation
The Laszlo compiler does simple partial evaluation of constants in `if` statements. This was seen as just as good as `#ifdef`, without having to invent a new syntax or have a pre-processor.
The compiler automatically defines the constant `$debug` to be `true` if you compile your application with `--debug`, or load it from the server with `?debug=true` and `false` otherwise. Similarly, it will define `swf`_N_ as `true` if you compile with `--runtime=swf`_N_ or load with `?lzr=swf`_N_ (for _N_ in the supported range, currently 6-8) and `false` otherwise.
You can define your own compile-time constants to `lzc` by using `-D`_name_`=`_value_, where _value_ should be either `true` or `false`. By convention, we use `$` as the first character of _name_, but nothing enforces that.
The compiler will compile only the chosen branch of an `if` statement when the condition expression is a compile-time constant (i.e., just the constant name, no other computation). For example:
if ($slow) {
... slow way ...
} else {
... fast way ...
}
Can be made to run fast by `lzc -D$slow=false`. If you don't supply a value for `$slow` at compile time, the compiler will emit both branches and the `if` statement will be evaluated at run time. There is currently no provision for passing compile-time constants through the server.
Clearly, this mechanism could be abused, making for very unreadable code, just as is the case with `#ifdef`. Compile-time constants should be used judiciously.








