Compile-time arguments

The SPL compiler, sc command, supports arguments that are passed in at compile time.

Compile-time arguments can be accessed from within SPL code through the following three compile-time argument access functions:

rstring getCompileTimeValue(rstring name)
rstring getCompileTimeValue(rstring name, rstring default)
list<rstring> getCompileTimeListValue(rstring name)

These functions can appear in any location within an SPL file, where an expression of the right type (matching the return type of the function) is expected. The first function, getCompileTimeValue, returns the value of a named argument as a string. It is a compile-time error if the string passed as the name argument is not specified on the compiler command line at compile time. The second function, getCompileTimeValue, returns the value of a named argument, or a default value in case the argument is not specified at compile time, as a string. The third function, getCompileTimeListValue, is similar to the first function, but it expects the value to be a string with commas. The string is split at the commas, and the result is returned as a list<rstring>. It is a compile-time error if the string passed as the name argument is not specified on the compiler command line at compile time. The name argument that is passed to these functions must be a compile-time expression that can be evaluated.

The named arguments are specified as <name>=<value> on the sc command. The name part cannot contain the character = but otherwise is a free form string. It matches the name parameter that is specified in calls that are made to the compile-time argument access functions from within SPL code. The value part of the command-line argument can be any string. An example is given as follows:

sc -M my::App hello=a,b,c foo=bar

# getCompileTimeValue("foo") == "bar"
# getCompileTimeValue("fred", "wilma") == "wilma"
# getCompileTimeListValue("hello") == ["a","b","c"]