Next: Quick Print, Previous: Session Support, Up: Session Support [Contents][Index]
Here is a read-eval-print-loop which, given an eval, evaluates forms.
read
s, repl:eval
s and write
s 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
.
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: