Gambit REPL is an interpreter for the Scheme programming language which closely conforms to the Scheme standard and also provides a large number of extensions. The following documents define the R5RS Scheme language and the extensions specific to the Gambit system, on which Gambit REPL is based.

- R5RS document

- Gambit extensions to R5RS

## Views

Gambit REPL's user interface provides 4 views which are selectable with the tabs at the top of the screen. The views can be switched from portrait to landscape by turning the device. The landscape layout is recommended on iPhone, as it gives a keyboard with more keys and text output with fewer line breaks.

- REPL
  This is the Read-Eval-Print-Loop with which the user interacts with the interpreter. Enter an expression to evaluate or a command, tap return and the interpreter will execute the command and display the resulting value(s) if there are any. Tap return on an empty line to dismiss the keyboard. Place the insertion point on a previous line and tap return to copy that line at the bottom. Tap the STOP key to interrupt a long computation (this key is available in landscape layout on small devices). The list of special comma commands can be listed by entering ,? (comma and question mark). On iPad, the keyboard function keys can be assigned scripts by naming the script with the name of the function key, for example F1.
- Wiki
  This view visits the Gambit wiki in the web browser. Internet access is required. The Gambit wiki contains useful information for using Gambit REPL and Gambit in general. The wiki can be edited by any user with an account (if you don't have an account you should create an account; it is free). Please contribute!
- Help
  This view gives access to the documentation. It contains the R5RS document and the Gambit manual, in HTML and PDF formats. The HTML formats include navigation buttons (move to previous/next section, table-of-contents, index, etc). Tap the x button in the upper right to return to the main help view.
- Edit
  This view contains a set of editable scripts. The first line of the script can be a comment containing the name of the script (three semicolons, a space, and the name of the script, such as main, F1, ~/test.scm). Giving names to scripts improves the usefulness of debugging messages, and it is necessary when saving scripts to the app's Documents folder. The main script is useful for customizing Gambit REPL; it is executed when the app is launched. By default the main script simply shows the splash screen, but this can be changed, for example, replacing the call `(splash)` by `(emacs)` will directly enter the emacs-like editor when the app is launched. Tap the + button to create a new empty script. Tap the Run button to execute the script. Tap the Save button to save the script to the Documents folder. The name of the script must start with ~/ followed by a letter, and end in .scm, and contain only letters, digits, '.', and '-'. Saving a script which only contains the script name will remove the script from the Documents folder. Tap the Delete button to delete the script from the Edit view.

## Specific Predefined Procedures

The following predefined procedures are specific to Gambit REPL.

- `(splash)`
  Shows the splash screen.
- `(repl)`
  Shows the REPL view.
- `(repl-eval` input`)`
  Shows the REPL view and simulates the user typing the characters in the string input. For example `(repl-eval "(+ 1 2)\n")`.
- `(wiki)`
  Shows the Wiki view.
- `(help)`
  Shows the Help view. The `help` procedure can also be called with a subject argument to open the appropriate section of the HTML documentation, for example `(help help)` gives the documentation of the `help` procedure.
- `(edit)`
  Shows the Edit view.
- `(open-URL` string`)`
  Opens the URL string in the web browser. For example, `(open-URL "http://www.apple.com")`.
- `(reset-scripts)`
  Resets the scripts in the Edit view to the factory default. It does not remove any files in the Documents folder. This operation cannot be undone, so please make sure you have saved any scripts you want to preserve, for example, by saving them to the Documents folder.
- `(repl-server` password`)`
  Starts the REPL server, which accepts password protected telnet connections on port 7000. This allows interacting with Gambit REPL from a remote computer, for example a desktop computer. It will be necessary to enter the password to authenticate the telnet connection. Assuming the device's address is 192.168.0.100, the following shell command on the remote computer (on the same LAN) will start a new REPL:
  `telnet 192.168.0.100 7000`
- `(emacs` [filename]`)`
  Starts an emacs-like editor. If file filename is specified (a string) it will be visited, otherwise a REPL is automatically started inside the editor. Exiting the editor with the command `C-x C-c` returns to the normal REPL view. The use of an external Bluetooth keyboard is recommended as it simplifies typing editing commands. More documentation on the editor is available in its help menu.

## File System

The Scheme file I/O procedures and the emacs-like editor can read and write files in a variety of locations. Paths not starting with "~" refer to files in the iCloud Documents folder which is kept in sync across devices. The path "~/" refers to the local Documents folder of the Gambit REPL app. This folder's content is preserved when Gambit REPL is updated to a newer version. The path "~~/" refers to the Gambit REPL app bundle (note that files in the app bundle are read-only).

## Reporting Problems

If you encounter problems with Gambit REPL, please submit a new issue on the Gambit issue tracker.