Next: , Previous: Session Support, Up: Session Support


7.5.1 Repl

(require 'repl) Here is a read-eval-print-loop which, given an eval, evaluates forms.

— Procedure: repl:top-level repl:eval

reads, repl:evals and writes expressions from (current-input-port) to (current-output-port) until an end-of-file is encountered. load, slib:eval, slib:error, and repl:quit dynamically bound during repl:top-level.

— Procedure: repl:quit

Exits from the invocation of repl:top-level.

The repl: procedures establish, as much as is possible to do portably, a top level environment supporting macros. repl:top-level uses dynamic-wind to catch error conditions and interrupts. If your implementation supports this you are all set.

Otherwise, if there is some way your implementation can catch error conditions and interrupts, then have them call slib:error. It will display its arguments and reenter repl:top-level. slib:error dynamically bound by repl:top-level.

To have your top level loop always use macros, add any interrupt catching lines and the following lines to your Scheme init file:

     (require 'macro)
     (require 'repl)
     (repl:top-level macro:eval)