Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

REST: P: Linus Torvalds S: Buried alive in email -- from /usr/src/linux/MAINTAINERS


devel / comp.lang.lisp / Puzzled by SBCL evaluating some Scheme code

SubjectAuthor
* Puzzled by SBCL evaluating some Scheme codeAxel Reichert
`* Re: Puzzled by SBCL evaluating some Scheme codeKaz Kylheku
 `- Re: Puzzled by SBCL evaluating some Scheme codeAxel Reichert

1
Puzzled by SBCL evaluating some Scheme code

<87o7b08a6t.fsf@axel-reichert.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=18115&group=comp.lang.lisp#18115

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mail@axel-reichert.de (Axel Reichert)
Newsgroups: comp.lang.lisp
Subject: Puzzled by SBCL evaluating some Scheme code
Date: Wed, 27 Mar 2024 07:23:38 +0100
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <87o7b08a6t.fsf@axel-reichert.de>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Wed, 27 Mar 2024 06:23:41 +0100 (CET)
Injection-Info: dont-email.me; posting-host="8b631b2f622e74f245abeb56af6c3d9c";
logging-data="2829635"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19WW+uI5izLU5aV9cTD7Spj2mN+MOX3E6E="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:llDKq4MTW+qmKH+qx6GJ7y69sTs=
sha1:BqpkH2/Yk2S3rYde4t3gu7sNJKg=
 by: Axel Reichert - Wed, 27 Mar 2024 06:23 UTC

Hello,

I am playing a bit with Guile and proceed along

https://scheme.com/tspl4/start.html#./start:h2

In a Scheme, exercise 2.2.3o

((car (list + - * /)) 2 3)

evaluates to 5. Of course, in Common Lisp this has to be written as

(funcall (car (list (function +)
(function -)
(function *)
(function /)))
2 3)

or, using reader macros, as

(funcall (car (list #'+ #'- #'* #'/)) 2 3)

or even, but not strictly identical anymore,

(funcall (car '(+ - * /)) 2 3)

However, at one point I managed to paste an expression into the wrong
REPL, SBCL instead of Guile, and got

(list + - * /)

evaluated by SBCL as

(NIL (LIST + - * /) NIL NIL)

Oops?! Even better, when I tried this again immediately, I got

((LIST + - * /) (LIST + - * /) (NIL (LIST + - * /) NIL NIL)
((NIL (LIST + - * /) NIL NIL)))

So there seems to be some "history expansion" going on (for "*"). But
how to explain the first result with the NILs and the expression itself?

Pointers welcome!

Axel

Re: Puzzled by SBCL evaluating some Scheme code

<20240326233251.513@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=18116&group=comp.lang.lisp#18116

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-6894@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: Puzzled by SBCL evaluating some Scheme code
Date: Wed, 27 Mar 2024 06:39:31 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <20240326233251.513@kylheku.com>
References: <87o7b08a6t.fsf@axel-reichert.de>
Injection-Date: Wed, 27 Mar 2024 06:39:31 +0100 (CET)
Injection-Info: dont-email.me; posting-host="8f377292846874240a48d49262348abc";
logging-data="2832309"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19hc/PnRfCOF4XaCtnmu+CMVdRnWgwqfOs="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:6svtFmjDRIQTe6XbJd3fF4fy+Ag=
 by: Kaz Kylheku - Wed, 27 Mar 2024 06:39 UTC

On 2024-03-27, Axel Reichert <mail@axel-reichert.de> wrote:
> However, at one point I managed to paste an expression into the wrong
> REPL, SBCL instead of Guile, and got
>
> (list + - * /)
> evaluated by SBCL as
>
> (NIL (LIST + - * /) NIL NIL)

In the Common Lisp interactive listener (a.k.a. REPL), there is a
standard variable called - which evaluates to the form currently
being evaluated:

https://www.lispworks.com/documentation/lw50/CLHS/Body/v__.htm

There are also variables +, ++ and +++, which hold less
recent values of -.

https://www.lispworks.com/documentation/lw50/CLHS/Body/v_pl_plp.htm

There also *, ** and ***, which hold the primary value of the
three most recent REPL evaluations, and:

https://www.lispworks.com/documentation/lw50/CLHS/Body/v__stst_.htm

As well as /, // and ///, which hold the lists of all the values
of the three most recent evaluations.

https://www.lispworks.com/documentation/lw50/CLHS/Body/v_sl_sls.htm

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Puzzled by SBCL evaluating some Scheme code

<87jzlo86mw.fsf@axel-reichert.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=18117&group=comp.lang.lisp#18117

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mail@axel-reichert.de (Axel Reichert)
Newsgroups: comp.lang.lisp
Subject: Re: Puzzled by SBCL evaluating some Scheme code
Date: Wed, 27 Mar 2024 08:40:23 +0100
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <87jzlo86mw.fsf@axel-reichert.de>
References: <87o7b08a6t.fsf@axel-reichert.de> <20240326233251.513@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Wed, 27 Mar 2024 07:40:24 +0100 (CET)
Injection-Info: dont-email.me; posting-host="8b631b2f622e74f245abeb56af6c3d9c";
logging-data="2858334"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+8y5mu7OJ5lUfIsHb+yCISwF9Lc7xBi1I="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:DuO+joSNYIFMajb/+HYaJE5Ugmw=
sha1:Ag9d+/T7oI7zx/65jMmuWLjVHfM=
 by: Axel Reichert - Wed, 27 Mar 2024 07:40 UTC

Kaz Kylheku <433-929-6894@kylheku.com> writes:

> In the Common Lisp interactive listener (a.k.a. REPL), there is a
> standard variable called - which evaluates to the form currently
> being evaluated:
>
> https://www.lispworks.com/documentation/lw50/CLHS/Body/v__.htm

Great, all clear now. I was aware of "*" and "**" etc., but not of the
others. My search in the SBCL docs was unsuccessful. I expected this to
be an implementation thing, not part of the hyperspec.

Many thanks!

Axel

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor