• Re: Writing HG LISP in Python, kind of

    From Aidan Kehoe@kehoea@parhasard.net to comp.lang.lisp on Tue Sep 23 20:28:19 2025
    From Newsgroup: comp.lang.lisp


    Ar an ceathr|| l|i d|-ag de m|! Aibre|in, scr|!obh Lawrence D'Oliveiro:

    On 14 Apr 2025 09:56:26 GMT, Stefan Ram wrote:

    Lisp's cons cells are conceptual, not just syntax.

    Is that why Lisp needs the separate concept of multi-value return, instead of doing simple destructuring assignment as both Python and JavaScript are able to do?

    LisprCOs #'destructuring-bind is available. But the stack is right there (for most people, most of the time), why not make use it as a cheap way to return multiple values?
    --
    rCyAs I sat looking up at the Guinness ad, I could never figure out /
    How your man stayed up on the surfboard after fourteen pints of stoutrCO
    (C. Moore)
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Jeff Barnett@jbb@notatt.com to comp.lang.lisp on Tue Sep 23 17:22:49 2025
    From Newsgroup: comp.lang.lisp

    On 9/23/2025 1:28 PM, Aidan Kehoe wrote:

    Ar an ceathr|| l|i d|-ag de m|! Aibre|in, scr|!obh Lawrence D'Oliveiro:

    > On 14 Apr 2025 09:56:26 GMT, Stefan Ram wrote:
    >
    > > Lisp's cons cells are conceptual, not just syntax.
    >
    > Is that why Lisp needs the separate concept of multi-value return, instead
    > of doing simple destructuring assignment as both Python and JavaScript are
    > able to do?

    LisprCOs #'destructuring-bind is available. But the stack is right there (for most people, most of the time), why not make use it as a cheap way to return multiple values?
    CL provides multi-value-setq as a macro I think) and it does the obvious thing. Since the head of this thread has been lopped off, I don't know
    if this form was previously discussed.
    --
    Jeff Barnett

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.lisp on Wed Sep 24 09:11:56 2025
    From Newsgroup: comp.lang.lisp

    On Tue, 23 Sep 2025 20:28:19 +0100, Aidan Kehoe wrote:

    Ar an ceathr|| l|i d|-ag de m|! Aibre|in, scr|!obh Lawrence D'Oliveiro:

    Is that why Lisp needs the separate concept of multi-value return,
    instead of doing simple destructuring assignment as both Python and
    JavaScript are able to do?

    LisprCOs #'destructuring-bind is available. But the stack is right
    there (for most people, most of the time), why not make use it as a
    cheap way to return multiple values?

    ThatrCOs an implementation issue, which is irrelevant to the way the
    language works. Python lets you write

    a, b = b, a

    as an easy way to swap the values of variables, for example.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Madhu@enometh@meer.net to comp.lang.lisp on Wed Sep 24 16:55:16 2025
    From Newsgroup: comp.lang.lisp

    * Lawrence DrCOOliveiro <10b0cks$3i6j6$1@dont-email.me> :
    Wrote on Wed, 24 Sep 2025 09:11:56 -0000 (UTC):
    On Tue, 23 Sep 2025 20:28:19 +0100, Aidan Kehoe wrote:
    Lawrence D'Oliveiro:

    Is that why Lisp needs the separate concept of multi-value return,
    instead of doing simple destructuring assignment as both Python and
    JavaScript are able to do?

    LisprCOs #'destructuring-bind is available. But the stack is right
    there (for most people, most of the time), why not make use it as a
    cheap way to return multiple values?

    ThatrCOs an implementation issue, which is irrelevant to the way the
    language works. Python lets you write

    a, b = b, a

    as an easy way to swap the values of variables, for example.

    What does this non-sequitur have to do with bindings (either
    destructuring or multiple values)?

    Mutation of bindings is handled in lisp through generalized references ("places") in a uniform way.

    (let ((a 10) (b 20)) (rotatef a b) (list a b))

    https://www.lispworks.com/documentation/HyperSpec/Body/m_shiftf.htm https://www.lispworks.com/documentation/HyperSpec/Body/05_a.htm

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Aidan Kehoe@kehoea@parhasard.net to comp.lang.lisp on Wed Sep 24 14:03:40 2025
    From Newsgroup: comp.lang.lisp


    Ar an ceathr|| l|i is fiche de m|! M|-an F||mhair, scr|!obh Lawrence DrCOOliveiro:

    On Tue, 23 Sep 2025 20:28:19 +0100, Aidan Kehoe wrote:

    Ar an ceathr|| l|i d|-ag de m|! Aibre|in, scr|!obh Lawrence D'Oliveiro:

    Is that why Lisp needs the separate concept of multi-value return,
    instead of doing simple destructuring assignment as both Python and
    JavaScript are able to do?

    LisprCOs #'destructuring-bind is available. But the stack is right
    there (for most people, most of the time), why not make use it as a
    cheap way to return multiple values?

    ThatrCOs an implementation issue, which is irrelevant to the way the language works.

    I used to think this back I took an interest in comp.lang.c, where people were unwilling to discuss aspects of the common implementations that did not fall under the standards. I thought they were 100% in the right.

    With time and maturity I have come to the realisation that there is *always* an underlying machine and an underlying language implementation, absent irrelevant Gedankenexperimente where software does not have to run. If the software written is multiplatform, there are more important (more used) and less important (less used) platforms.

    What can be implemented, and what can be implemented in a performant way, guides language design. Language design guides how a language works.

    Python lets you write

    a, b = b, a

    as an easy way to swap the values of variables, for example.

    Madhu has followed this up fairly comprehensively.
    --
    rCyAs I sat looking up at the Guinness ad, I could never figure out /
    How your man stayed up on the surfboard after fourteen pints of stoutrCO
    (C. Moore)
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From tpeplt@tpeplt@gmail.com to comp.lang.lisp on Wed Sep 24 14:59:05 2025
    From Newsgroup: comp.lang.lisp

    Madhu <enometh@meer.net> writes:


    ThatrCOs an implementation issue, which is irrelevant to the way the
    language works. Python lets you write

    a, b = b, a

    as an easy way to swap the values of variables, for example.

    What does this non-sequitur have to do with bindings (either
    destructuring or multiple values)?

    Mutation of bindings is handled in lisp through generalized references ("places") in a uniform way.

    (let ((a 10) (b 20)) (rotatef a b) (list a b))

    https://www.lispworks.com/documentation/HyperSpec/Body/m_shiftf.htm https://www.lispworks.com/documentation/HyperSpec/Body/05_a.htm


    Did you mean to reference the documentation for ROTATEF?

    rCym_shiftf.htmrCO is the page that documents the macro SHIFTF.

    rCym_rotatef.htmrCO is the page that documents the macro ROTATEF.

    At the www.ai.mit.edu website, they have expanded the rCym_rCO
    to rCymac_rCO to provide a longer hint that a page documents a
    macro:

    http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/mac_rotatef.html
    --
    The lyf so short, the craft so long to lerne.
    - Geoffrey Chaucer, The Parliament of Birds.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.lisp on Wed Sep 24 20:33:13 2025
    From Newsgroup: comp.lang.lisp

    On Wed, 24 Sep 2025 14:03:40 +0100, Aidan Kehoe wrote:

    With time and maturity I have come to the realisation that there is
    *always* an underlying machine and an underlying language
    implementation ...

    With popular languages, there are typically multiple implementations,
    often built on very different implementation concepts.

    This is the case with Python, just for example.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.lisp on Wed Sep 24 20:34:54 2025
    From Newsgroup: comp.lang.lisp

    On Wed, 24 Sep 2025 16:55:16 +0530, Madhu wrote:

    * Lawrence DrCOOliveiro <10b0cks$3i6j6$1@dont-email.me> :

    a, b = b, a

    What does this ... have to do with bindings (either
    destructuring or multiple values)?

    Structuring on the RHS, destructuring on the LHS. All happens
    automatically, without you even having to think about it.

    Maybe more obvious if you put in the optional parentheses, to make
    explicit that there is only a single expression on the RHS:

    (a, b) = (b, a)
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Aidan Kehoe@kehoea@parhasard.net to comp.lang.lisp on Thu Sep 25 05:58:53 2025
    From Newsgroup: comp.lang.lisp


    Ar an ceathr|| l|i is fiche de m|! M|-an F||mhair, scr|!obh Lawrence DrCOOliveiro:

    On Wed, 24 Sep 2025 14:03:40 +0100, Aidan Kehoe wrote:

    With time and maturity I have come to the realisation that there is *always* an underlying machine and an underlying language
    implementation ...

    With popular languages, there are typically multiple implementations,
    often built on very different implementation concepts.

    And very few of them have no stack, or no heap, or are implemented on drum-memory computers, or use an underlying integer representation that is other than twosrCO complement.

    This is the case with Python, just for example.
    --
    rCyAs I sat looking up at the Guinness ad, I could never figure out /
    How your man stayed up on the surfboard after fourteen pints of stoutrCO
    (C. Moore)
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Aidan Kehoe@kehoea@parhasard.net to comp.lang.lisp on Thu Sep 25 06:07:09 2025
    From Newsgroup: comp.lang.lisp


    Ar an ceathr|| l|i is fiche de m|! M|-an F||mhair, scr|!obh Lawrence DrCOOliveiro:

    On Wed, 24 Sep 2025 16:55:16 +0530, Madhu wrote:

    * Lawrence DrCOOliveiro <10b0cks$3i6j6$1@dont-email.me> :

    a, b = b, a

    What does this ... have to do with bindings (either
    destructuring or multiple values)?

    Structuring on the RHS, destructuring on the LHS. All happens automatically, without you even having to think about it.

    Well, you need to know the syntax.

    Lisp does not have infix operators. ThatrCOs a basic design decision. Once yourCOve
    accepted that, (multiple-value-setq (a b) (values b a)) is not any less elegant than your example above.

    Maybe more obvious if you put in the optional parentheses, to make explicit that there is only a single expression on the RHS:

    (a, b) = (b, a)
    --
    rCyAs I sat looking up at the Guinness ad, I could never figure out /
    How your man stayed up on the surfboard after fourteen pints of stoutrCO
    (C. Moore)
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.lisp on Thu Sep 25 05:49:51 2025
    From Newsgroup: comp.lang.lisp

    On Thu, 25 Sep 2025 06:07:09 +0100, Aidan Kehoe wrote:

    Lisp does not have infix operators. ThatrCOs a basic design decision.

    Which is entirely separate from the issue of destructuring assignment.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to comp.lang.lisp on Thu Sep 25 05:50:40 2025
    From Newsgroup: comp.lang.lisp

    On Thu, 25 Sep 2025 05:58:53 +0100, Aidan Kehoe wrote:

    Ar an ceathr|| l|i is fiche de m|! M|-an F||mhair, scr|!obh Lawrence DrCOOliveiro:

    With popular languages, there are typically multiple
    implementations, often built on very different implementation
    concepts.

    And very few of them have no stack, or no heap, or are implemented
    on drum-memory computers, or use an underlying integer
    representation that is other than twosrCO complement.

    Or have no register file, nowadays, while werCOre at it.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From ram@ram@zedat.fu-berlin.de (Stefan Ram) to comp.lang.lisp on Fri Sep 26 20:12:47 2025
    From Newsgroup: comp.lang.lisp

    Lawrence =?iso-8859-13?q?D=FFOliveiro?= <ldo@nz.invalid> wrote or quoted: >Structuring on the RHS, destructuring on the LHS. All happens
    automatically, without you even having to think about it.
    Maybe more obvious if you put in the optional parentheses, to make
    explicit that there is only a single expression on the RHS:
    (a, b) = (b, a)

    Another example: Assume, "s" is a set with one element, a singleton,
    then you can write,

    m, = s

    , idiomatic Python, the meaning of which is left as an exercise to
    the reader.

    BTW: I now have written an implementation of what I still remember
    of HG LISP in Python. It can execute the Y^HZ combinator. Hope to
    be able to publish it one day, but packing it as a package properly
    and writing documentation is more work than the actual implementation!

    Some test code I used so far (not sure if it all actually executes
    correctly, but I think most should):

    (CAR (LAMBDA (X) X))

    '(1 . 2)

    '(1 2)

    (CONS 'A 'B)

    'A

    (SETQ Z-COMBINATOR
    (LAMBDA (f)
    ((LAMBDA (x) (f (LAMBDA (v) ((x x) v))))
    (LAMBDA (x) (f (LAMBDA (v) ((x x) v)))))))

    (SETQ FACT-GEN
    (LAMBDA (fact)
    (LAMBDA (n)
    (IF (= n 0)
    1
    (* n (fact (- n 1)))))))

    (SETQ FACT (Z-COMBINATOR FACT-GEN))

    (FACT 5)

    (((LAMBDA (X)
    (LAMBDA (Y) (+ X Y)))
    5)
    3)


    --- Synchronet 3.21a-Linux NewsLink 1.2