On this page:
16.1.1 Initialization
16.1.2 Exit Status
16.1.3 Init Libraries
16.1.4 Command Line
Version: 4.2.1

16.1 Running MzScheme or MrEd

The core PLT Scheme run-time system is available in two main variants:

16.1.1 Initialization

On startup, the top-level environment contains no bindings – not even #%app for function application. Primitive modules with names that start with #% are defined, but they are not meant for direct use, and the set of such modules can change. For example, the '#%kernel module is eventually used to bootstrap the implemetation of scheme/base, and '#%mred-kernel is used for scheme/gui/base.

The first action of MzScheme or MrEd is to initialize current-library-collection-paths to the result of (find-library-collection-paths pre-extras extras), where pre-extras is normally null and extras are extra directory paths provided in order in the command line with -S/--search. An executable created from the MzScheme or MrEd executable can embed paths used as pre-extras.

MzScheme and MrEd next require scheme/init and scheme/gui/init, respectively, but only if the command line does not specify a require flag (-t/--require, -l/--lib, or -u/--require-script) before any eval, load, or read-eval-print-loop flag (-e/--eval, -f/--load, -r/--script, -m/--main, or -i/--repl). The initialization library can be changed with the -I configuration option.

After potentially loading the initialization module, expression evals, files loads, and module requires are executed in the order that they are provided on the command line. If any raises an uncaught exception, then the remaining evals, loads, and requires are skipped.

After running all command-line expressions, files, and modules, MzScheme or MrEd then starts a read-eval-print loop for interactive evaluation if no command line flags are provided other than configuration options. If any command-line argument is provided that is not a configuration option, then the read-eval-print-loop is not started, unless the -i/--repl flag is provided on the command line to specifically re-enable it. In addition, just before the command line is started, MzScheme loads the file (find-system-path 'init-file) and MrEd loads the file (find-graphical-system-path 'init-file) is loaded, unless the -q/--no-init-file flag is specified on the command line.

Finally, before MrEd exists, it waits for all frames to class, all timers to stop, etc. in the main eventspace by evaluating (scheme 'yield). This waiting step can be suppressed with the -V/--no-yield command-line flag.

16.1.2 Exit Status

The default exit status for a MzScheme or MrEd process is non-zero if an error occurs during a command-line eval (via -e, etc.), load (via -f, -r, etc.), or require (via --l, -t, etc.), but only when no read-eval-print loop is started. Otherwise, the default exit status is 0.

In all cases, a call to exit (when the default exit handler is in place) can end the process with a specific status value.

16.1.3 Init Libraries

The scheme/init library is the default start-up library for MzScheme. It re-exports the scheme, scheme/enter and scheme/help libraries, and it sets current-print to use pretty-print.

The scheme/gui/init library is the default start-up library for MrEd. It re-exports the scheme/init and scheme/gui/base libraries, and it sets current-load to use text-editor-load-handler.

16.1.4 Command Line

The MzScheme and MrEd executables recognize the following command-line flags:

If at least one command-line argument is provided, and if the first one after any configuration option is not a flag, then a -u/--–require-script flag is implicitly added before the first non-flag argument.

If no command-line arguments are supplied other than configuration options, then the -i/--–repl flag is effectively added.

For MrEd under X11, the follow flags are recognized when they appear at the beginning of the command line, and they count as configuration options (i.e., they do not disable the read-eval-print loop or prevent the insertion of -u/--require-script):

Similarly, under Mac OS X, a leading switch starting with -psn_ is treated as a special configuration option. It indicates that Finder started the application, so the current input, output, and error output are redirected to a GUI window.

Multiple single-letter switches (the ones preceded by a single -) can be collapsed into a single switch by concatenating the letters, as long as the first switch is not --. The arguments for each switch are placed after the collapsed switches (in the order of the switches). For example,

  -ifve file expr

and

  -i -f file -v -e expr

are equivalent. If a collapsed -- appears before other collapsed switches in the same collapsed set, it is implicitly moved to the end of the collapsed set.

Extra arguments following the last option are available from the current-command-line-arguments parameter.