The REPL
> require("repl") #<Atomy::Module 'repl.ay'>
basic-repl(bnd = TOPLEVEL_BINDING) => _ | bnd is-a(Binding)?
The basics of a REPL - reading, evaluating, and printing in a loop. More flexibility is provided by various signals. See repl
for a fancier REPL, which builds upon this, and ReplDebugger
.
When showing the prompt, .prompt
is signaled with a .use-prompt
restart available. Invoke this restart and pass along a string to override the prompt, which defaults to >>
.
Input preceded by a colon (:
) and followed by an alphanumeric character is assumed to be a special command. These are not evaluated, and are signaled as .special(text)
.
When the user sends EOF
(Ctrl+D) or an interrupt (Ctrl+C), .quit
is signaled.
When the user enters code, .input(text)
is signaled. The code is evaluated with two restarts registered: .retry
for re-attempting evaluation, and .abort
, for canceling the evaluation. After the code is evaluated, .evaluated(result)
is signaled.
.loop
is signaled before the loop starts over again (i.e., after the input is handled).
An interactive debugger REPL for handling errors. This will list the results along with a number, allow the user to continue evaluating code, and once they enter a special command in the form of :number
, the specified restart will be invoked.
repl(history = nil, bnd = TOPLEVEL_BINDING) => _ | history is-a(String)? | bnd is-a(Binding)?
A more feature-filled REPL, providing persistent history and setting Debugger
to ReplDebugger
.
History will be managed and appended to a file specified by history
upon termination.