www.delorie.com/gnu/docs/kawa/kawa_21.html   search  
 
Buy GNU books!


Kawa, the Java-based Scheme system

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.2 Compiling Scheme to a set of .class files

Invoking `kawa' (or `java kawa.repl') with the `-C' flag will compile a `.scm' source file into one or more `.class' files:
 
kawa --main -C myprog.scm

You run it as follows:
 
kawa [-d outdirectory] [-P prefix] [-T topname] [--main | --spplet] -C infile ...

Note the `-C' must come last, because `Kawa' processes the arguments and options in order,

Here:

`-C infile ...'
The Scheme source files we want to compile.
`-d outdirectory'
The directory under which the resulting `.class' files will be. The default is the current directory.
`-P prefix'
A string to prepend to the generated class names. The default is the empty string.
`-T topname'
The name of the "top" class - i.e. the one that contains the code for the top-level expressions and definitions. The default is generated from the infile and prefix.
`--main'
Generate a main method so that the resulting "top" class can be used as a stand-alone application. See section 6.3 Compiling Scheme to a standalone application.
`--applet'
The resulting class inherits from java.applet.Applet, and can be used as an applet. See section 6.4 Compiling Scheme to an applet.
`--servlet'
The resulting class implements javax.servlet.http.HttpServlet, and can be used as an servlet in a servlet container like Tomcat.
`--module-static'
If no module-static is specified, generate a static module (as if (module-static #t) were specified. See section 10.8 Modules and how they are compiled to classes.

When you actually want to load the classes, the outdirectory must be in your `CLASSPATH'. You can use the standard load function to load the code, by specifying the top-level class, either as a file name (relative to outdirectory) or a class name. E.g. if you did:
 
kawa -d /usr/local/share/java -P my.lib. -T foo -C foosrc.scm
you can use either:
 
(load "my.lib.foo")
or:
 
(load "my/lib/foo.class")

If you are compiling a Scheme source file (say `foosrc.scm') that uses macros defined in some other file (say `macs.scm'), you need to make sure the definitions are visible to the compiler. One way to do that is with the `-f':
 
kawa -f macs.scm -C foosrc.scm


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003