Previous: , Up: Invocation   [Contents][Index]

4.3 Interactive enviroment

When you invoke the stand-alone librep interpreter without giving it a script to execute the system is started in interactive mode. This means that the REPL is entered—the read-eval-print loop.

The read-eval-print loop simply reads complete Lisp forms (see The Lisp Reader), evaluates them, before printing the result back to the console; this continues ad infinitum, or until you force an EOF (i.e. enter C-d), or until you enter ,quit command.

The REPL works as its name suggests. It reads Lisp forms from the console, evaluates them, and then prints the result back to the console. Here is an example REPL session:

user> (+ 1 1)
user> (cons 'a 'b)
(a . b)

The ‘user>’ string is the prompt that the REPL prints when it is waiting for an input form. This form may span several lines, e.g.:

user> (cons 'a
(a . b)

The prompt above contains the string ‘user’. This is the name of the module that the form will be evaluated in (see Modules).

As well as allowing arbitrary Lisp forms to be entered and evaluated, the REPL provides a rich set of meta-commands, these are used to configure and inspect the state of the system, as well as providing convenient shortcuts for common operations.

A meta-command is differentiated from a normal Lisp form by preceding it with a comma (‘,’) character. The name of the command should follow the comma, with any argument forms after that. Note that unlike normal Lisp forms, no parentheses are used to mark the command application.

For example the whereis meta-command searches all loaded modules for those exporting a particular symbol. It might be used as follows:

user> ,whereis string-match
string-match is exported by: rep.regexp

The following table lists all currently supported meta-commands:

access struct

Add the modules named struct … to the list of structures whose exported definitions may be accessed by the current module (using the structure-ref special form).


Print the names of the modules whose contents may be accessed using the structure-ref form from the current module.

apropos "regexp"

Print the definitions in the scope of the current module whose names match the regular expression regexp.


Print all bindings in the current module.


Run the garbage collector.

compile [struct …]

Compile any uncompiled functions in the modules named struct …. If no named modules are given, use the current module.

compile-proc procedure

Compile the functions called procedure … in the current module.

describe symbol

Look for documentation describing the current meaning of symbol, if any is found, print it.

dis form

Disassemble the bytecode form or compiled function that is the result of evaluating form.

expand form

Print form with any outermost macro calls recursively expanded.


Print the names of the variables exported from the current module.


List all REPL commands.


Print the names of the modules imported by the current module.

in struct [form]

If form is given, temporarily switch to the module called struct, evaluate form printing the result, then switch back to the original module.

If form isn’t given, simply switch the current module to be struct.


Print all defined module interfaces, and their definitions.

load struct

Attempt to load the module called struct.

load-file "filename" …

Load the file of Lisp forms called filename.

locate symbol

Recursively scan from the current module for the module providing the binding of symbol.

new struct

Create a new module called struct, and set it as the current module. It will import the rep.module-system module, but nothing else (i.e. no actual language).

open struct

Import the modules called struct … to the current module. This is analogous to the open clause in the configuration form of the module’s definition.

profile form

Evaluate form, recording information about the frequency and duration of the calls it makes to subroutines (and the calls they make, and so on). This information is tabulated and printed after the evaluation has finished.


Terminate the Lisp interpreter.

reload struct

Reload the modules called struct …. If modules of these names had previously been loaded, they will be deallocated when there are no remaining references to them.

Note that importing the interface of one module into another does not create object references between the two modules (the references are purely symbolic). However, each closure (i.e. function) created in a module does contain a reference to the module it was created in.

step form

Evaluate form in single-step mode (using the debugger).


Print the names of all currently defined modules.

time form

Evaluate the form form, print the result and the time it took to perform the evaluation.

unload struct

Attempt to unload the modules called struct …. As with reloading, unloading a module only removes the link between the module name and the module body. Only once no more references exist to the module body will it be freed.

whereis symbol

Scan all loaded modules for those that export a binding of symbol, and print the results.

Repl imports some modules by default. They are rep,,, rep.module-system, rep.regexp, and rep.system. It is so because the repl itself needs them.

Don’t confuse the interactive environment provided by rep command with Sawfish’s one - sawfish-client; it does not evaluate any, but it merely sends expressions to the running instance of Sawfish window manager, and prints the result. (see Sawfish Manual in The Sawfish Manual.)

Previous: , Up: Invocation   [Contents][Index]