When mzscheme is run with no command-line arguments (other than confguration options, like -j), then it starts a REPL with a > prompt:
Welcome to MzScheme
For information on GNU Readline support, see readline.
To initialize the REPL’s environment, mzscheme first requires the scheme/init module, which provides all of scheme, and also installs pretty-print for display results. Finally, mzscheme loads the file reported by (find-system-path 'init-file), if it exists, before starting the REPL.
If any command-line arguments are provided (other than configuration options), add -i or --repl to re-enable the REPL. For example,
mzscheme -e '(display "hi\n")' -i
displays “hi” on start-up, but still presents a REPL.
If module-requiring flags appear before -i/--repl, they cancel the automatic requiring of scheme/init. This behavior can be used to initialize the REPL’s environment with a different language. For example,
mzscheme -l scheme/base -i
starts a REPL using a much smaller initial language (that loads much faster). Beware that most modules do not provide the basic syntax of Scheme, including function-call syntax and require. For example,
mzscheme -l scheme/date -i
produces a REPL that fails for every expression, because scheme/date provides only a few functions, and not the #%top-interaction and #%app bindings that are needed to evaluate top-level function calls in the REPL.
If a module-requiring flag appears after -i/--repl instead of before it, then the module is required after scheme/init to augment the initial environment. For example,
mzscheme -i -l scheme/date
If a file argument is supplied to mzscheme before any command-line switch (other than configuration options), then the file is required as a module, and (unless -i/--repl is specified), no REPL is started. For example,
requires the "hello.ss" module and then exits. Any argument after the file name, flag or otherwise, is preserved as a command-line argument for use by the required module via current-command-line-arguments.
If command-line flags are used, then the -u or --require-script flag can be used to explicitly require a file as a module. The -t or --require flag is similar, except that additional command-line flags are processed by mzscheme, instead of preserved for the required module. For example,
mzscheme -t hello.ss -t goodbye.ss
requires the "hello.ss" module, then requires the "goodbye.ss" module, and then exits.
The -l or --lib flag is similar to -t/--require, but it requires a module using a lib module path instead of a file path. For example,
mzscheme -l compiler
is the same as running the mzc executable with no arguments, since the compiler module is the main mzc module.
Note that if you wanted to pass command-line flags to compiler above, you would need to protect the flags with a --, so that mzscheme doesn’t try to parse them itself:
mzscheme -l compiler -- --make prog.ss
The -f or --load flag supports loading top-level expressions in a file directly, as opposed to expressions within a module file. This evaluation is like starting a REPL and typing the expressions directly, except that the results are not printed. For example,
mzscheme -f hi.ss
The -e or --eval flag accepts an expression to evaluate directly. Unlike file loading, the result of the expression is printed, as in a REPL. For example,
mzscheme -e '(current-seconds)'
prints the number of seconds since January 1, 1970.
mzscheme -l scheme/base -e '(current-seconds)'