Command-line arguments

You can pass various flags to Kawa, for example:

kawa -e '(display (+ 12 4))(newline)'

or:

java kawa.repl -e '(display (+ 12 4))(newline)'

Either causes Kawa to print ‘16’, and then exit.

At startup, Kawa executes an init file from the user's home directory. The init file is named .kawarc.scm on Unix-like systems (those for which the file separator is '/'), and kawarc.scm on other systems. This is done before the read-eval-print loop or before the first -f or -c argument. (It is not run for a -e command, to allow you to set options to override the defaults.)

If there are further command-line arguments after the options have been processed, then the first remaining argument names a file that is read and evaluated. If there is no such argument, then Kawa enters an interactive read-eval-print loop, but only if none of the ‘-c’, ‘-e’, ‘-f’, ‘-s’, ‘-C’, or ‘--’ options were specified.

General options

-e expr

Kawa evaluates expr, which contains one or more Scheme expressions. Does not cause the ~/.kawarc.scm init file to be run.

-c expr

Same as ‘-e expr’, except that it does cause the ~/.kawarc.scm init file to be run.

-f filename-or-url

Kawa reads and evaluates expressions from the file named by filename-or-url. If the latter is ‘-’, standard input is read (with no prompting). Otherwise, it is equivalent to evaluating ‘(load "filename-or-url")’. The filename-or-url is interpreted as a URL if it is absolute - it starts with a "URI scheme" like http:.

-s
--

The global variable ‘command-line-arguments’ is set to the remaining arguments (if any), and an interactive read-eval-print loop is started. This uses the same "console" as where you started up Kawa; use ‘-w’ to get a new window.

-w

Creates a new top-level window, and runs an interactive read-eval-print in the new window. See Running a Command Interpreter in a new Window. Same as -e (scheme-window #t). You can specify multiple ‘-w’ options, and also use ‘-s’.

--help

Prints out some help.

--version

Prints out the Kawa version number, and then exits.

--server portnum

Start a server listening from connections on the specified portnum. Each connection using the Telnet protocol causes a new read-eval-print-loop to started. This option allows you to connect using any Telnet client program to a remote "Kawa server".

Options for language selection

--scheme

Set the default language to Scheme. (This is the default unless you select another language, or you name a file with a known extension on the command-line.)

--elisp
--emacs
--emacs-lisp

Set the default language to Emacs Lisp. (The implementation is quite incomplete.)

--lisp
--clisp
--clisp
--commonlisp
--common-lisp

Set the default language to CommonLisp. (The implementation is very incomplete.)

--krl

Set the default language to KRL. See KRL - The Kawa Report Language for generating XML/HTML.

--brl

Set the default language to KRL, in BRL-compatibility mode. See KRL - The Kawa Report Language for generating XML/HTML.

--xquery

Set the default language to the draft XML Query language. See the Kawa-XQuery page for more information.

--xslt

Set the default language to XSLT (XML Stylesheet Language Transformations). (The implementation is very incomplete.) See the Kawa-XSLT page for more information.

Options for setting variable

name=value

Set the global variable with the specified name to the given value. The type of the value is currently unspecified; the plan is for it to be like XQuery's untyped atomic which can be coerced as needed.

{namespace-uri}local-name=value

Set the global variable with the specified namespace uri and namespace-local name to the given value.

Options for controlling output formatting

--output-format format
--format format

Change the default output format to that specified by format. See Named output formats for more information and a list.

out:base=integer

The number base (radix) to use by default when printing rational numbers. Must be an integer between 2 and 36, and the default is of course 10. For example the option out:base=16 produces hexadecimal output. Equivalent to setting the *print-base* variable.

out:radix=no|yes

If true, prints an indicator of the radix used when printing rational numbers. The default is no. Equivalent to setting the *print-radix* variable.

out:doctype-system=system-identifier

If out:doctype-system is specified then a DOCTYPE declaration is written before writing a top-level XML element, using the specified system-identifier.

out:doctype-public=public-identifier

Ignored unless out:doctype-system is also specified, in which case the public-identifier is written as the public identifiers of the DOCTYPE declaration.

out:xml-indent=kind

Controls whether extra line breaks and indentation are added when printing XML. If kind is always or yes then newlines and appropriate indentation are added before and after each element. If kind is pretty then the pretty-printer is used to only add new lines when an element otherwise won't fit on a single line. If kind is no (the default) then no extra line breaks or indentation are added.

out:line-length=columns
out:right-margin=columns

Specifies the maximum number of number of columns in a line when the pretty-printer decides where to break a line. (The two options are equivalent.)

Options for compiling and optimizing

The following options control which calling conventions are used:

--full-tailcalls

Use a calling convention that supports proper tail recursion.

--no-full-tailcalls

Use a calling convention that does not support proper tail recursion. Self-tail-recursion (i.e. a recursive call to the current function) is still implemented correctly, assuming that the called function is known at compile time.

--no-inline

Disable inlining of known functions and methods. The generated code runs slower, but you can more reliably trace procedures. Normally Kawa will assume that a procedure fn declared using a (define (fn args) body) form is constant, assuming it isn't modified in the current module. However, it is possible some other module might modify the binding of fn. You can use the --no-inline to disable the assumption that fn is constant.

The default is currently --no-full-tailcalls because it is usually faster. It is also closer to the Java call model, so may be better for people primarily interested in using Kawa for scripting Java systems.

Both calling conventions can co-exist: Code compiled with --full-tailcalls can call code compiled with --no-full-tailcalls and vice versa.

The options ‘-C’, ‘-d’, ‘-T’, ‘-P’, ‘--main’ ‘--applet’, and --servlet are used to compile a Scheme file; see Compiling to a set of .class files. The option ‘--connect portnum’ is only used by the ‘kawa’ front-end program.

Options for debugging

The following options are useful if you want to debug or understand how Kawa works.

--debug-dump-zip

Normally, when Kawa loads a soyrce file, or evaluates a non-trivial expression, it generates new internal Java classes but does not write them out. This option asks it to write out generated classes in a ‘.zip’ archive whose name has the prefix ‘kawa-zip-dump-’.

--debug-print-expr

Kawa translates source language forms into an internal Expression data structure. This option causes that data structure to be written out in a readable format to the standard output.

--debug-print-final-expr

Similar to the previous option, but prints out the Expression after various transformations and optimizations have been done, and just before code generation.