• Re: Puzzled by SBCL evaluating some Scheme code

    From Kaz Kylheku@21:1/5 to Axel Reichert on Wed Mar 27 06:39:31 2024
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Axel Reichert@21:1/5 to All on Wed Mar 27 07:23:38 2024
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Axel Reichert@21:1/5 to Kaz Kylheku on Wed Mar 27 08:40:23 2024
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)