# (chibi repl)

A user-friendly REPL with line editing and signal handling. The default REPL provided by chibi-scheme is very minimal, meant primarily to be small and work on any platform. This module provides an advanced REPL that handles vt100 line editing and signal handling, so that C-c will interrupt a computation and bring you back to the REPL prompt. To use this repl, run

    chibi-scheme -R

from the command line or within Emacs.Runs an interactive REPL. Repeatedly displays a prompt, then Reads an expression, Evaluates the expression, Prints the result then Loops. Terminates when the end of input is reached or the `\exit` command is given.

Basic Emacs-style line editing with persistent history completion is provided. C-c can be used to interrupt the current computation and drop back to the prompt. The following keyword arguments customize the REPL:

- `in:` - the input port (default `(current-input-port)`)
- `out:` - the output port (default `(current-output-port)`)
- `module:` - the initial module
- `environment:` - the initial environment (default `(interaction-environment)`)
- `escape:` - the command escape character (default `#\\`)
- `make-prompt:` - a procedure taking one argument (the current module name as a list) and returning a string to be used as the prompt
- `history:` - the initial command history
- `history-file:` - the file to save history to (default ~/.chibi-repl-history)

The module: and environment: keyword arguments should not both be given.

REPL commands in the style of Scheme48 are available to control out-of-band properties. By default a command is written as an identifier beginning with an "@" character, but this can be customized with the `escape:` keyword. The following commands are available:

- `\import <import-spec>` - import the `<import-spec>` in the `interaction-environment`, useful if the `import` binding is not available
- `\import-only <import-spec>` - replace the `interaction-environment` with the given `<import-spec>`
- `\in [<module>]` - switch to `<module>`, or the `interaction-environment` if `<module>` is not specified
- `\meta <expr>` - evaluate `<expr>` in the `(meta)` module
- `\meta-module-is <module>` - switch the meta module to `<module>`
- `\exit` - exit the REPL

The results of the last ten successful evaluations are available via a history facility. `$0` holds the most recent result while `$9` holds the tenth-most recent result. Evaluations yielding single values are stored as single values while evaluations that yield multiple values are stored as lists of values.

#### `$0`

#### `$1`

#### `$2`

#### `$3`

#### `$4`

#### `$5`

#### `$6`

#### `$7`

#### `$8`

#### `$9`

#### `(repl . o)`