2 The REPL
dxtr edited this page 2026-10-19 08:16:58 +02:00

The REPL

The editor's REPL dock, beside the Output dock under the main screen, has a REPL for each session its code runs in, as SLY can have several: the editor's own, and, while a game plays, one for the game, which goes with it. Each is on a tab of its own, Editor and Game, so a form never runs in another session than the one you chose; the game's REPL sees the game's resources, settings and session values, as its threads do.

CL-USER> (+ 1 2)
3
CL-USER> (in-package #:pyssel)
#<PACKAGE "PYSSEL">
PYSSEL> (values (list 1 "two" :three) (* 6 7))
(1 "two" :THREE)
42

Typing

A REPL reads with a code edit, as the Script screen edits a file: Lisp is coloured, brackets and strings close as they are typed, Return indents as Emacs does, Control+Space completes and the hint above shows the lambda list of the operator around the caret, each read in the package the REPL reads in, which its prompt names. The input grows with its lines, up to eight.

Key Does
Return Send the input once its forms are complete; before, open a line, indented
Shift+Return Open a line
Up, at the input's first line The input sent before the one shown
Down, at the input's last line The input sent after it, and past the newest, what you were writing
Control+Up, Control+Down The same, wherever the caret is, as Emacs's comint has them

The inputs sent are kept for the editor's life, the newest 500, and any REPL of the dock goes back through all of them. The Clear button clears the transcript shown.

Evaluating

A REPL evaluates on a thread of its own, one input after another, so the editor draws on while a form runs, with pyssel:*session* bound to its session. It reads the forms of an input one after another, so an in-package among them changes how the rest read, and it binds *package*, which keeps what in-package set from one input to the next, and *, **, ***, +, ++, +++, /, //, /// and -, as the standard REPL does. What a form prints to *standard-output*, *error-output* or *trace-output* shows in the transcript, the compiler's warnings among it, and then the values of the input's last form, each on a line as prin1 prints it with the thread's printer variables, at most 10,000 characters of it, a link that inspects it in the Inspector dock, or ; No values. A form that reads gets the end of its input at once. An error or a break brings the REPL's thread into the Debugger dock, where it waits: its ABORT restart, Return to the Editor REPL., says ; Evaluation aborted. in the transcript, and the REPL goes on. The Interrupt button, while the REPL shown evaluates, breaks into what it does, as SLY's C-c C-c does.

The transcript and the Output dock show their text in the editor theme's code font, as Godot's Output dock does.

Thread rules

The REPL dock is the editor's tree's, used on its thread; each REPL evaluates on a thread of its own, named pyssel REPL Editor or pyssel REPL Game, and hands what it found back to the editor's tree. A game's REPL's thread ends with the play, once the input it evaluates, if any, is done, and every REPL's with the editor.