Scheme 48 Manual -- Command processor support

Scheme 48 Manual | Contents | In Chapter: Module system
Previous: Semantics of configuration mutation | Next: Configuration packages

## Command processor support

While it is possible to use the Scheme 48 static linker for program development, it is far more convenient to use the development environment, which supports rapid turnaround for program changes. The programmer interacts with the development environment through a command processor. The command processor is like the usual Lisp read-eval-print loop in that it accepts Scheme forms to evaluate. However, all meta-level operations, such as exiting the Scheme system or requests for trace output, are handled by commands, which are lexically distinguished from Scheme forms. This arrangement is borrowed from the Symbolics Lisp Machine system, and is reminiscent of non-Lisp debuggers. Commands are a little easier to type than Scheme forms (no parentheses, so you don't have to shift), but more importantly, making them distinct from Scheme forms ensures that programs' namespaces aren't cluttered with inappropriate bindings. Equivalently, the command set is available for use regardless of what bindings happen to be visible in the current program. This is especially important in conjunction with the module system, which puts strict controls on visibility of bindings.

The Scheme 48 command processor supports the module system with a variety of special commands. For commands that require structure names, these names are resolved in a designated configuration package that is distinct from the current package for evaluating Scheme forms given to the command processor. The command processor interprets Scheme forms in a particular current package, and there are commands that move the command processor between different packages.

Commands are introduced by a comma (`,`) and end at the end of line. The command processor's prompt consists of the name of the current package followed by a greater-than (`>`).

  `,open `struct-name`*`
  The `,open` command opens a new structure in the current package, as if the package's definition's `open` clause had listed `struct-name`.

  `,config`
  The `,config` command sets the command processor's current package to be the current configuration package. Forms entered at this point are interpreted as being configuration language forms, not Scheme forms.

  `,config `command``
  This form of the `,config` command executes another command in the current configuration package. For example,

  >     ,config ,load foo.scm

  interprets configuration language forms from the file `foo.scm` in the current configuration package.

  `,config-package-is `struct-name``
  The `,config-package-is` command designates a new configuration package for use by the `,config` command and resolution of `struct-name`s for other commands such as `,in` and `,open`. See below for information on making new configuration packages.

  `,in `struct-name``
  The `,in` command moves the command processor to a specified structure's underlying package. For example:

  >     user> ,config
  >     config> (define-structure foo (export a)
  >               (open scheme))
  >     config> ,in foo
  >     foo> (define a 13)
  >     foo> a
  >     13

  In this example the command processor starts in a package called `user`, but the `,config` command moves it into the configuration package, which has the name `config`. The `define-structure` form binds, in `config`, the name `foo` to a structure that exports `a`. Finally, the command `,in foo` moves the command processor into structure `foo`'s underlying package.

  A package's body isn't executed (evaluated) until the package is loaded, which is accomplished by the `,load-package` command.

  `,in `struct-name` `command``
  This form of the `,in` command executes a single command in the specified package without moving the command processor into that package. Example:

  >     ,in mumble (cons 1 2)
  >     ,in mumble ,trace foo

  `,user [`command`]`
  This is similar to the `,config` and `,in` commands. It moves to or executes a command in the user package (which is the default package when the Scheme 48 command processor starts).

  `,user-package-is `name``
  The `,user-package-is` command designates a new user package for use by the `,user` command.

  `,load-package `struct-name``
  The `,load-package` command ensures that the specified structure's underlying package's program has been loaded. This consists of (1) recursively ensuring that the packages of any opened or accessed structures are loaded, followed by (2) executing the package's body as specified by its definition's `begin` and `files` forms.
  `,reload-package `struct-name``
  This command re-executes the structure's package's program. It is most useful if the program comes from a file or files, when it will update the package's bindings after mutations to its source file.

  `,load `filespec` ...`
  The `,load` command executes forms from the specified file or files in the current package. `,load `filespec`` is similar to `(load "`filespec`")` except that the name `load` needn't be bound in the current package to Scheme's `load` procedure.

  `,for-syntax [`command`]`
  This is similar to the `,config` and `,in` commands. It moves to or executes a command in the current package's "package for syntax," which is the package in which the forms f in `(define-syntax `name` `f`)` are evaluated.

  `,new-package`
  The `,new-package` command creates a new package, in which only the standard Scheme bindings are visible, and moves the command processor to it.

  `,structure `name` `interface``
  The `,structure` command defines `name` in the configuration package to be a structure with interface `interface` based on the current package.

Previous: Semantics of configuration mutation | Next: Configuration packages