Skip to content

REPL Extensions in Standalone EXE

Anton Kovalenko edited this page Aug 23, 2011 · 9 revisions

REPL extensions in standalone executables

Prebuilt standalone SBCL executables for Windows include a few modules from “SYS:CONTRIB;” collection. This list includes an extended REPL (SB-ACLREPL module).

When building standalone executable images, I add some features to SB-ACLREPL (this part of build process uses noticeable amount of code that is unpublished now).

New commands

SB-ACLREPL:ALIAS facility is used for their definition; the standard :aliases command prints a list of them, with a brief description of each one.

Current command set provides a convenient way of bootstrapping Quicklisp and loading systems provided by its repository.

Bootstrapping happens automatically when a Quicklisp-related command is entered for the first time, unless quicklisp is already loaded by other means at that moment: initial quicklisp.lisp (loaded from a socket stream) brings in another parts and the repository metadata.

Arguments for this kind of commands are never evaluated. They should be either symbols or string literals; non-qualified symbols that are used as string designators are not interned to the current *package* (internally, a special temporal package is used to achieve this).

Command :qload system...

Load one or more systems.

Command :qapropos some-text

Search system and release names in Quicklisp repository; list matching systems (the facility itself is provided by QL-DIST:SYSTEM-APROPOS).

Command :qupdate optional-dist-names-to-update...

Update Quicklisp metadata. With no arguments, update all subscribed dists and also Quicklisp client.

Command :qslime

Experimental: start SWANK server and SLIME client on local machine. This command is available since sbcl-1.0.51.6.mswinmt.919.

Multiple things happen here, even if we forget quicklisp bootstrapping. First, swank and quicklisp-slime-helper are quickloaded; then a registry is examined for Emacs installation (emacs_dir value under SOFTWARE/GNU/Emacs key, in HKCU and HKLM; the value at HKLM is written by EmacsW32 project’s install wizard). If Emacs installation root is found during this step, emacsclientw.exe, runemacs.exe or emacs.exe is started with command-line options that should make it load SLIME (from the quickloaded release) and connect to SBCL binary that received :qslime command.

If Emacs installation root is not found by reading the registry, an open file dialog is displayed (“Where is your emacs?”), and the answer is used to start SLIME. If emacsclientw.exe is available in the same directory as the selected executable (which is supposed to be runemacs.exe or emacs.exe), this command will prefer it.

I’m going to make some customization of this command’s behavior possible, if it proves to be useful; even now, it is a good tool to have SLIME running as soon as possible, if all you have is a modern GNU Emacs and one of my SBCL executables.

Command :lsloaded

Very Experimental: list ASDF systems that were loaded. Expect it to be broken or unreliable; for now, it’s the single command that works with ASDF directly; that would be bad enough, but it may also be affected by method definitions provided by particular systems.

Outer Parentheses May Be Omitted

I’ve reimplemented a facility from some older REPL (I don’t remember its name, only the idea): for ordinary S-expressions, a new postprocessing step was added. If a command line starts with a symbol that is FBOUND, but makes no sense as variable, the line is reinterpreted as if there were additional parentheses around (the precondition I use is probably stronger than expected; the purpose is to avoid any reinterpretation unless it’s obviously makes more sense than the original form).

Reinterpreted form is pretty-printed (with ;;; line prefix) before execution. Here is an example REPL session fragment:

CL-USER(9): list 1 2 3
;;;  => (LIST 1 2 3)
(1 2 3)
CL-USER(10): 

REPL Override Warning

There are some other variants of extended REPL, like the one provided by a (quicklispable) GBBopen project. Some users may prefer SB-ACLREPL with the extensions, even if they need some of GBBopen modules.

If SB-INT:*REPL-READ-FORM-FUN* is modified but a prompt code is left intact, a simple warning will be signalled before the next REPL prompt:

WARNING:
   REPL behavior was overridden to use #<FUNCTION EXTENDED-REPL-READ-FORM-FUN>
   for reading forms. Among other things, it may mean that our Quicklisp
   goodies, like :qload and :qapropos, won't be available any more. Invoke
   (RESTORE-ACLREPL) to get back the form reader provided by SB-ACLREPL.

As it says, (COMMON-LISP-USER:RESTORE-ACLREPL) rolls back the changes; after it’s invoked, the original SB-ACLREPL with extensions will be used for all new listeners (including those created by default toplevel function of the dumped image).

Clone this wiki locally