Re: on racket and other Lisps

Liste des GroupesRevenir à cl lisp 
Sujet : Re: on racket and other Lisps
De : markw (at) *nospam* distorted.org.uk (Mark Wooding)
Groupes : comp.lang.lisp
Date : 30. May 2024, 16:20:50
Autres entêtes
Message-ID : <86ikyv8jp9.fsf.markw@stratocaster.distorted.org.uk>
References : 1 2 3
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
"B. Pym" <No_spamming@noWhere_7073.org> writes:

On 1/4/2024, George Neuner wrote:
>
Racket is derived from Scheme (which also is NOT Lisp).
>
The following code snippet runs under both Gauche Scheme and
SBCL, and the output is identical:
>
[...]
>
Does this tend to prove that Scheme is not a Lisp?

I think you're looking in the wrong place.

One of Lisp's most obvious defining features is its homoiconicity.  This
wasn't always appreciated.  Lisp 2 wanted an Algoloid surface syntax; I
don't know how this would have worked, but probably it would have
abandoned homoiconicity, and I probably wouldn't think of it as a Lisp.

Lisp, as we understand it now, starts out by defining a syntax for
literal data: symbols, numbers, strings, arrays, and, of course, cons
cells and lists.  As a next step, it defines semantics for a subset of
these data items as a programming language.  The result is a language
which is particularly good at thinking about itself.

One standard feature of Lisp languages is the special operator `quote'.
In a properly homoiconic Lisp, `quote' is /trivial/: if X is any datum,
then the result of evaluating (quote X) is X itself.

(Aside: am I alone in thinking that (quote X Y ... Z) ought to be
defined, and equivalent to (values (quote X) (quote Y) ... (quote Z))?)

This is not true in Scheme.  The R4RS appendix introduced a hygienic
macro system which is incompatible with homoiconicity as demonstrated
through `quote'.  For example:

        (define-syntax demo
          (syntax-rules ()
            ((_ form)
             (begin (write (quote form)) (newline) form))))

        (let ((x 1))
          (let-syntax ((whoops
                        (syntax-rules ()
                          ((_ y)
                           (let ((x 2))
                             (demo (values y x)))))))
            (whoops x)))
        ; -| (values x x)
        ; => 1 2

If we're to believe `quote', then the form being evaluated is
(values x x), which should return two copies of the same value.  But it
actually returns two different values -- how can this be?

Maybe `write' isn't up to the job and the two `x' symbols in that list
aren't actually the same.

        (define-syntax inspect
          (syntax-rules ()
            ((_ (expr . vals) form . body)
             (let ((expr (quote form)))
               (call-with-values (lambda () form) (lambda vals . body))))))

        (let ((x 1))
          (letrec ((show (lambda (which what x)
                           (display which)
                           (write-char #\space)
                           (display what)
                           (display " = ")
                           (write x)
                           (newline)))
                   (compare (lambda (what whats x y)
                              (show "first" what x)
                              (show "second" what y)
                              (display whats)
                              (display #\space)
                              (display (if (eq? x y) "equal" "unequal"))
                              (newline)))
                   (report (lambda (expr a b)
                             (compare "argument" "arguments"
                                      (cadr expr) (caddr expr))
                             (compare "value" "values"
                                      a b)
                             (values a b))))
            (let-syntax ((gotcha
                          (syntax-rules ()
                            ((_ y)
                             (let ((x 2))
                               (inspect (expr a b) (values y x)
                                 (report expr a b)))))))
              (gotcha x))))
        ; -| first argument = x
        ; -| second argument = x
        ; -| arguments equal
        ; -| first value = 1
        ; -| second value = 2
        ; -| values unequal
        ; => 1 2

That seems conclusive: `eq?' thinks that the two `x's are the same
symbol, but they sure don't behave the same.

Of course, what's going on here is that Scheme's hygienic macros don't
see /symbols/: they see /identifiers/ which maintain additional
information about which scope they're bound in, and `quote' strips this
information away.  Which means that `quote' is nontrivial, and Scheme is
heteroiconic.

I think R3RS Scheme was a Lisp.  However, the report describes
expression syntax in terms of /characters/ rather than in terms of
Scheme data items which, in retrospect, should have been seen as a
warning.

Those who program in CL (COBOL-Like) are using the Loop language,
which is not a dialect of Lisp.  Furthermore, they are forcing those
who read their code to learn the Loop language.

Nobody forces you to use `loop' in Common Lisp, and it's not like it's
particularly hard to read.  I could understand if the hill you wanted to
die on was Common Lisp's `format' syntax (though I'm a fan, and you'll
have to prise `format' out of my cold, dead hands), but `loop' is just
not that big a deal.

About the only thing it has which isn't obviously available elsewhere is
a means for building lists efficiently in order.

Let's just say that Scheme is a better Lisp than CL (COBOL-Like) is.

No.  Scheme is not a Lisp.

-- [mdw]

Date Sujet#  Auteur
28 May 24 * Re: on racket and other Lisps18B. Pym
28 May 24 +- Re: on racket and other Lisps1Lawrence D'Oliveiro
28 May 24 +* Re: on racket and other Lisps6De ongekruisigde (ds.)
29 May 24 i`* Re: on racket and other Lisps5Lawrence D'Oliveiro
29 May 24 i `* Re: on racket and other Lisps4De ongekruisigde (ds.)
29 May 24 i  +* Re: on racket and other Lisps2Cor
30 May 24 i  i`- Re: on racket and other Lisps1Lawrence D'Oliveiro
30 May 24 i  `- Re: on racket and other Lisps1steve
30 May 24 `* Re: on racket and other Lisps10Mark Wooding
1 Jun 24  `* Re: on racket and other Lisps9Lawrence D'Oliveiro
1 Jun 24   `* Re: on racket and other Lisps8Julieta Shem
1 Jun 24    `* Re: on racket and other Lisps7Lawrence D'Oliveiro
1 Jun 24     `* Re: on racket and other Lisps6Julieta Shem
2 Jun 24      `* Re: on racket and other Lisps5Lawrence D'Oliveiro
2 Jun 24       +- Re: on racket and other Lisps1Kaz Kylheku
5 Jun 24       `* Re: on racket and other Lisps3Mark Wooding
5 Jun 24        `* Re: on racket and other Lisps2Stefan Monnier
5 Jun 24         `- Re: on racket and other Lisps1Madhu

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal