Article View: comp.lang.lisp
Article #26Re: REPL, streams, SBCL
From: Lawrence D’Oliveiro
Date: Mon, 12 Oct 2026 23:23
Date: Mon, 12 Oct 2026 23:23
82 lines
3364 bytes
3364 bytes
On Mon, 12 Oct 2026 17:32:46 -0400, steve g wrote:
> I was interested in changing the REPL for SBCL.
Probably easier to run it in an environment like Jupyter. Even without
a custom SBCL kernel, just the regular “%%script magic” already lets
you do some useful things.
←
%%script sbcl
(+ 2 2)
→
This is SBCL 2.6.4.debian, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* 4
*
You probably want to turn off the startup banner message, and the “*”
characters from the default prompting for input by the REPL. The
`--script` option does this, but it also turns off automatic output of
expression values:
←
%%script sbcl --script
(+ 2 2) ; produces no output
(princ (+ 2 2)) ; need to do explicit output
→
4
This may be OK for running functional scripts, but it is not so
convenient for simple experimentation.
Alternatively, the `--noinform` option turns off the startup banner.
You can then change the prompt to the empty string by setting the
SBCL-specific `sb-aclrepl:*prompt*` variable. To access this, you need
to `require` the `sb-aclrepl` package. To avoid spurious output, this
can all be done with `--eval` options on the command line:
←
%%script sbcl --noinform --eval "(require 'sb-aclrepl)" --eval "(setq sb-aclrepl:*prompt* \"\")"
(+ 2 2)
→
4
Gets a bit complicated, but at least it’s not always necessary ...
Computing the first n terms of a Fibonacci series:
←
%%script sbcl --script
(defvar n 15) ; change as required
(do
(
(a 1 (+ a b))
(b 1 a)
(i 0 (+ i 1))
)
((>= i n))
(format *standard-output* "~A~%" a)
) ; do
→
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
Technical Details
Message-ID:
<11ajq5a$2i7p$1@dont-email.me>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<87wlrmeha9.fsf@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Lawrence D’Oliveiro <ldo@nz.invalid> Newsgroups: comp.lang.lisp Subject: Re: REPL, streams, SBCL Date: Mon, 12 Oct 2026 23:23:23 -0000 (UTC) Organization: A noiseless patient Spider Lines: 82 Message-ID: <11ajq5a$2i7p$1@dont-email.me> References: <87wlrmeha9.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Mon, 12 Oct 2026 23:23:23 +0000 (UTC) Injection-Info: dont-email.me; logging-data="84217"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX189YYn957NXhSfIXlFhGI+N"; posting-host="5afb7f6ae0d3013d5ddae53a50b48bb2" User-Agent: Pan/0.165 (Kostiantynivka) Cancel-Lock: sha1:y2sLZSx12iC/3AlAHiEZF2Kcbd0= sha256:MvS+9WnWy8UDtoYeK5OcvCZR0W1ivxRt27XAXtkjqR4= sha1:z7CrKr22ajE2NPJmXuAc+qoauZ8= sha256:d52FsJcHBf4pyX53RWgiHio2oYzYbtwJ4fpZ6Vrqa4g=