Menu

keywords-conditional

Will Pittenger

Used to declared variables that can be accessed during compilation for [Conditional compilation]. Each conditional variable must be an immutable type from a project that's already compiled. All conditional variables are required to be global and must be declared outside all types. This allows you to use types other than simple strings and primitives. Each compiler must also provide a some means of declaring a conditional variable from the makefile or command line.

You test the value stored in the conditional variable with the conditionalif statement. It works just like a normal if/then/else statement, but can reference only conditional variables. It does, however, use then and else. If you're testing whether a conditional variable exists or not, prefix it with the exists keyword. All compilers must issue an error if they encounter an identifier in a conditionalif's condition and that identifier doesn't exist.

You can reference a conditional variable in your code outside a conditionalif statement's condition. However, you can only change its value or undeclare it at global scope.

If you do need to undeclare a conditional, use the conditional keyword again with the same identifier, but now, instead of a value, put a dash there. Omit the type. Only conditional variables declared in a file can be undeclared by that file. So if the conditional variable was declared through the makefile or compiler command line, it can't be undeclared at all.

conditional String s = "test"
conditional i% = 3
conditional foo

conditionalif exists foo ' True
  conditionalif s = "fast" ' false
    ' Some code
  else conditionalif i% = 3 ' True
    ' Some more code

conditional s - ' Undeclare

Related

Wiki: Appendices-Terms-r-value
Wiki: Attributes
Wiki: Conditional compilation
Wiki: Keywords
Wiki: Sets
Wiki: keywords-conditionalif
Wiki: keywords-const
Wiki: keywords-else
Wiki: keywords-exists
Wiki: keywords-then
Wiki: keywords-var
Wiki: operators-brackets