The Mythryl compiler supports a simple hack to allow executing short fragments of code at compiletime, just before a file is compiled:
#DO set_control "compiler::verbose_compile_log" "TRUE";
As illustrated, the main intended use for this facility is to set compiler switches. (Setting the illustrated switch at the top of a foo.pkg file will result in verbose compile logging into foo.pkg.compile.log.) A full list of available switches and their current settings may be obtained by executing show_controls() at the interactive prompt:
linux% my Mythryl 126.96.36.199.3 built Tue Sep 13 00:48:57 2011 Do help(); for help. eval: show_controls(); Compiler controls: tracing/debugging/profiling: tdp::instrument = FALSE makelib: makelib::verbose = TRUE makelib::debug = FALSE ... eval:
More than one #DO statement may be included in a file; the compiler will evaluate them in order of appearance.
Very few of these are of current use, or even documented; two of the most useful applications of #DO are enabling integer overflow trapping when desired (next section) and disabling vector and matrix index bounds-checking when not desired (section after that).
The current implementation of #DO is something of a kludge; in particular the lexer simply scans until it reaches a semicolon, which means the code to be executed cannot contain a semicolon internally, even in a quoted string (say). Currently it can also not contain a newline. For the intended purpose this is not a problem; if it becomes a problem, the lexer code can be upgraded.
The #DO statement syntax is supported only at top level; it will not be recognized inside of a package or such. Also, no matter where in the file a #DO statement is located, it will always be evaluated before compiling any code in the file. To avoid confusion, it is best to place such statements at the top of the source file, before the main api or package code to be compiled.