Daniel Barlow wrote:
> Having seen at how few places a replacement prompt/toplevel needs to
> touch the existing code, I now actually favour the latter approach
> (and feel a bit bad about having encouraged Kevin to write this as a
> patch to SBCL itself). Suppose we do something like (off the top of
> my head, untested)
In general, I like the idea of hooks. ACL's toplevel, as an example,
has special variables for *read*, *eval*, and *print* which can be set
by the user to override the defaults for it's toplevel
listener. Despite the numerous special variables that ACL uses to
control the behaviour of it's toplevel listener, ACL does not include
a hook to change the listener itself. Perhaps because the listener
also integrates the inspector and debugger.
> (defvar *repl-read-function* 'read
> "Function with the signature of READ that the toplevel calls to get
> the next form to evaluate")
> (defvar *repl-prompt-function*
> (lambda (stream)
> (fresh-line stream)
> (write-string "* " stream)
> (force-output stream))
> "Function of one argument STREAM that the toplevel will call when
> it wants to prompt the user for input"
That's a good start. It can be made more general, I think. Particulary, to
implement history for a listener, it'd to nice to be have a hook which
can call an initialization function for the listener.
Also, my patch does more than just return a form. A structure is
returned to the evaluate and print loop. This allows overloading so
that unique *null-cmd* and *eof-cmd* cant be returned. By returning
*eof-cmd* along with the special variable *exit-on-eof*, the behaviour
of EOF can be customized to the user's liking.
> then hack REPL to funcall the said variables, I think that the rest of
> Kevin's patch could be implemented in, for want of a better word,
> user-space. That would also mean that it could then take advantage of
> CLOS and other stuff that we only have in a fully defrosted SBCL.
Christophe has mentioned the advantages of have a contrib section of
the SBCL distribution.
> I've never used the Allegro toplevel in any meaningful way, but even
> so there is one feature in this patch that I definitely want to see in
> (my local customisations to) SBCL: the ':cd' command. It's way too
> verbose, and too easy to screw up, changing the
> *default-pathname-defaults* right now
:cd is nice. I'm also particular fond of using ":cl a b c" to compile
(if necessary) and load files a, b, and c. I frequently use history
recall, :<history-number>, to re-execute a command.
> (I wonder, incidentally, if this customisable toplevel could actually
> be used to improve the reliability of ilisp, by having it rebind the
> prompt to something that it knows, instead of having to guess it based
> on a regex)
ILISP can call an SBCL command to return an regex suitable for the
Kevin Rosenberg | .''`. ** Debian GNU/Linux **
http://b9.com/debian.html | : :' : The universal
GPG signed and encrypted | `. `' Operating System
messages accepted. | `- http://www.debian.org/