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.
Gambit REPL's user interface provides 4 views which are selectable with the tabs at the bottom 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 wider keys and text output with fewer line breaks.
- REPL
This is the Read-Eval-Print-Loop with which the user can interact 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 the 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, F12, test.scm). Giving names to scripts improves the usefulness of debugging messages, and it is necessary when saving scripts to the Documents folder. The main script is useful for customizing Gambit REPL; it is executed when the app is launched (by default it simply shows the splash screen). 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 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.
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
The Scheme file I/O procedures will read and write files in an area specific to the Gambit REPL app. The path "~" refers to the Documents folder. It is a convenient place to store files. This folder is initially empty. The content of the folder will be preserved when you update Gambit REPL to a newer version. The path "~~" refers to the Gambit REPL app bundle.