1.9 Compiling to Raw Bytecode (original) (raw)

1.9 Compiling to Raw Bytecode🔗

The --no-deps mode for raco make is an improverished form of the compilation, because it does not track import dependencies. It does, however, support compilation of non-module source in a namespace that initially imports scheme.

Outside of a module, top-level define-syntaxes,module, #%require,define-values-for-syntax, and begin expressions are handled specially by raco make --no-deps: the compile-time portion of the expression is evaluated, because it might affect later expressions.

For example, when compiling the file containing

the class form from the racket/class library must be bound in the compilation namespace at compile time. Thus, therequire expression is both compiled (to appear in the output code) and evaluated (for further computation).

Many definition forms expand to define-syntaxes. For example,define-signature expands to define-syntaxes. In--no-deps mode, raco make --no-deps detectsdefine-syntaxes and other expressions after expansion, so top-level define-signature expressions affect the compilation of later expressions, as a programmer would expect.

In contrast, a load or eval expression in a source file is compiled—but not evaluated!—as the source file is compiled. Even if the load expression loads syntax or signature definitions, these will not be loaded as the file is compiled. The same is true of application expressions that affect the reader, such as (read-case-sensitive #t). The -p or--prefix flag for raco make takes a file and loads it before compiling the source files specified on the command line.

By default, the namespace for compilation is initialized by arequire of scheme. If the --no-primflag is specified, the namespace is instead initialized withnamespace-require/copy, which allows mutation and redefinition of all initial bindings (other than syntactic forms, in the case of mutation).

In general, a better solution is to put all code to compile into a module and use raco make in its default mode.