All Scheme functions and source files are invisibly compiled into internal Java byte-codes. (A traditional interpreter is used for macro-expansion. Kawa used to also interpret “simple” expressions in interactive mode, but always compiling makes things more consistent, and allows for better stack traces on errors.)
To save speed when loading large Scheme source files, you probably want to pre-compile them and save them on your local disk. There are two ways to do this.
You can compile a Scheme source file to a single archive file.
You do this using the compile-file
function.
The result is a single file that you can move around and load
just like the .scm
source file. You just specify the name
of the archive file to the load
procedure.
Currently, the archive is a "zip" archive and has extension ".zip";
a future release will probably use "Java Archive" (jar) files.
The advantage of compiling to an archive is that it is simple
and transparent.
Alternatively, you can compile a Scheme source file to a
collection of ‘.class’ files.
You then use the standard Java class loading mechanism to load the code.
The compiled class files do have to be installed somewhere
in the CLASSPATH
.
• Files compilation: | Compiling to a set of .class files | |
• Archive compilation: | Compiling to an archive file | |
• Compiling using Ant: | ||
• Application compilation: | Compiling to a standalone application | |
• Applet compilation: | Compiling to an applet | |
• Compiling to executable: | Compiling to a native executable |