#
Chapter 11
`compile.ss`: Compiling Files

To load: `(require (lib "compile.ss"))`

`(compile-file``` `src``` [`dest filter`]`)` P R O C E D U R E

Compiles the Scheme file `src` and saves the compiled code to `dest`. If `dest` is not specified, a filename is constructed by taking `src`'s directory path, adding a `compiled` subdirectory, and then adding `src`'s filename with its suffix replaced by `.zo`. Also, if `dest` is not provided and the `compiled` subdirectory does not already exist, the subdirectory is created. If the `filter` procedure is provided, it is applied to each source expression and the result is compiled (otherwise, the identity function is used as the filter). The result of `compile-file` is the destination file's path.

The `compile-file` procedure is designed for compiling modules files; each expression in `src` is compiled independently. If `src` does not contain a single `module` expression, then earlier expressions can affect the compilation of later expressions when `src` is loaded directly. An appropriate `filter` can make compilation behave like evaluation, but the problem is also solved (as much as possible) by the `compile-zos` procedure provided by the `compiler` collection's `compiler.ss` module.

See also `managed-compile-zo` in section 6.