Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Uncompensated overtime? Just Say No.


devel / comp.lang.lisp / Why is `lambda` not a special form

SubjectAuthor
* Why is `lambda` not a special formStefan Monnier
+* Re: Why is `lambda` not a special formSam Steingold
|+* Re: Why is `lambda` not a special formStefan Monnier
||`- Re: Why is `lambda` not a special formSam Steingold
|`- Re: Why is `lambda` not a special formKaz Kylheku
+* Re: Why is `lambda` not a special formKaz Kylheku
|`* Re: Why is `lambda` not a special formStefan Monnier
| +* Re: Why is `lambda` not a special formKaz Kylheku
| |`* Re: Why is `lambda` not a special formStefan Monnier
| | `* Re: Why is `lambda` not a special formKaz Kylheku
| |  `* Re: Why is `lambda` not a special formStefan Monnier
| |   +* Re: Why is `lambda` not a special formMadhu
| |   |+- Re: Why is `lambda` not a special formZyni Moë
| |   |+* Re: Why is `lambda` not a special formStefan Monnier
| |   ||`- Re: Why is `lambda` not a special formMadhu
| |   |`- Re: Why is `lambda` not a special formPo Lu
| |   `* Re: Why is `lambda` not a special formKaz Kylheku
| |    `- Re: Why is `lambda` not a special formStefan Monnier
| `* Re: Why is `lambda` not a special formZyni Moë
|  `* Re: Why is `lambda` not a special formStefan Monnier
|   `* Re: Why is `lambda` not a special formZyni Moë
|    `- Re: Why is `lambda` not a special formStefan Monnier
+* Re: Why is `lambda` not a special formZyni Moë
|`* Re: Why is `lambda` not a special formStefan Monnier
| `* Re: Why is `lambda` not a special formZyni Moë
|  `- Re: Why is `lambda` not a special formStefan Monnier
`* Re: Why is `lambda` not a special formJeff Barnett
 `- Re: Why is `lambda` not a special formStefan Monnier

Pages:12
Why is `lambda` not a special form

<jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: monnier@iro.umontreal.ca (Stefan Monnier)
Newsgroups: comp.lang.lisp
Subject: Why is `lambda` not a special form
Date: Tue, 15 Feb 2022 09:35:18 -0500
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="f5eb5aba23f1f57d35d02e72b57d6302";
logging-data="10544"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/SNgf4L8WgH4NAKO1BhlMJ"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
Cancel-Lock: sha1:eOTttiNukiDhXgyt2pDRl3Ld9Rk=
sha1:aDQOMvIasvtqS97FhlRWhDn5vi0=
 by: Stefan Monnier - Tue, 15 Feb 2022 14:35 UTC

Does someone know of an article or rationale explaining why `lambda` is
a macro, i.e. why the fully-expanded code needs to be (function (lambda
....)) rather than just (lambda ...)?

I can guess its origin as an accident of history, but I think there's
been enough years between the introduction of #' to fix the accident and
the design of Common Lisp to have it fixed, so I'm wondering if there
were other reasons to keep `lambda` as something that's relegated to
`function` as opposed to being a special-form.

Stefan

Re: Why is `lambda` not a special form

<lziltgnn5m.fsf@3c22fb11fdab.ant.amazon.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: sds@gnu.org (Sam Steingold)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Tue, 15 Feb 2022 10:51:33 -0500
Organization: disorganization
Lines: 18
Message-ID: <lziltgnn5m.fsf@3c22fb11fdab.ant.amazon.com>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
Reply-To: sds@gnu.org
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="69a70bf572e2343599b3e5416723b991";
logging-data="18802"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/aXZXkXeAaK84cHQzUKszF"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin)
Cancel-Lock: sha1:eWw5PVKRrhQadPhrVjYnOAG8fT0=
sha1:7Tm8sNTYQ2+tOrxtzl0maxSPRcw=
Return-Receipt-To: sds@gnu.org
X-Disclaimer: You should not expect anyone to agree with me.
X-Attribution: Sam
 by: Sam Steingold - Tue, 15 Feb 2022 15:51 UTC

> * Stefan Monnier <zbaavre@veb.hzbagerny.pn> [2022-02-15 09:35:18 -0500]:
>
> Does someone know of an article or rationale explaining why `lambda` is
> a macro, i.e. why the fully-expanded code needs to be (function (lambda
> ...)) rather than just (lambda ...)?

Speaking as an implementor, a macro is "cheaper" than a special
operator, so _requiring_ something to be a special operator is a weird
thing to do unless there is a compelling reason for that.

I can implement a macro as a SO if I want to but I am not allowed to
implement a SO as a macro (IIRC).

--
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.2113
http://childpsy.net http://calmchildstories.com http://steingoldpsychology.com
http://think-israel.org https://ij.org/ https://iris.org.il https://camera.org
Let us remember that ours is a nation of lawyers and order.

Re: Why is `lambda` not a special form

<jwvleycdsk6.fsf-monnier+comp.lang.lisp@gnu.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: monnier@iro.umontreal.ca (Stefan Monnier)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Tue, 15 Feb 2022 11:08:23 -0500
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <jwvleycdsk6.fsf-monnier+comp.lang.lisp@gnu.org>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<lziltgnn5m.fsf@3c22fb11fdab.ant.amazon.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="f5eb5aba23f1f57d35d02e72b57d6302";
logging-data="25788"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+H8VmY/cteh+7D76D0vvFB"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
Cancel-Lock: sha1:9XLUfWVWwpgCTmkozP8ZddCTLz4=
sha1:hQ/Gr6uSJOxgTuTXJgi7aoJmZAY=
 by: Stefan Monnier - Tue, 15 Feb 2022 16:08 UTC

Sam Steingold [2022-02-15 10:51:33] wrote:
>> * Stefan Monnier <zbaavre@veb.hzbagerny.pn> [2022-02-15 09:35:18 -0500]:
>> Does someone know of an article or rationale explaining why `lambda` is
>> a macro, i.e. why the fully-expanded code needs to be (function (lambda
>> ...)) rather than just (lambda ...)?
> Speaking as an implementor, a macro is "cheaper" than a special
> operator, so _requiring_ something to be a special operator is a weird
> thing to do unless there is a compelling reason for that.

But any Common Lisp implementation will need to have special handling of
(function (lambda ...)) and I fail to see how it would be cheaper than
moving that work to a (lambda ...) special form.

Stefan

Re: Why is `lambda` not a special form

<20220215080700.39@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 480-992-1380@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Tue, 15 Feb 2022 16:25:10 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <20220215080700.39@kylheku.com>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
Injection-Date: Tue, 15 Feb 2022 16:25:10 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="2bde51fdd18c24d4fadc45b645fc7da3";
logging-data="28037"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+s+BET1YVJTcW2/YXNejPdEBDInzl9tRo="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:gMRSIBjTYkLsUBz1sbIUIjB5kY4=
 by: Kaz Kylheku - Tue, 15 Feb 2022 16:25 UTC

On 2022-02-15, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> Does someone know of an article or rationale explaining why `lambda` is
> a macro, i.e. why the fully-expanded code needs to be (function (lambda
> ...)) rather than just (lambda ...)?

I've always understood this macro to be a compatibility device.

In Common Lisp, lambda is #'(lambda () ...); the macro removes the #'
dirt that doesn't appear in some other dialects, for better
compatibility.

If Common Lisp made lambda a special form, it would still need two
flavors of lambda.

If we have lambda as a special form here:

(mapcar (lambda (...) ...) ...)

where it is a form, we still need a story which explains what lambda is in

((lambda (...) ...) ...)

where it cannot be a special form, since it isn't a form.

The "unified theory of Common Lisp lambda" is that lambda is an expression,
which serves in place of a function name. Whereas a name like (setf foo)
or xyzzy denotes a function binding that exists elsewhere, the lambda
expression, in a name-like way, literally denotes the function described
by itself.

It's very tidy, except for the bit of #' dirt that appears on lambda; so
then the lambda macro is thrown in to appease those who don't want that.

And of course, (function (lambda () ...)) *is* a special form.
It has to do all the work of a (lambda () ...) special form in another
dialect; it's just dispatched under the locus of the function operator.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: Why is `lambda` not a special form

<20220215082522.230@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 480-992-1380@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Tue, 15 Feb 2022 16:30:55 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <20220215082522.230@kylheku.com>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<lziltgnn5m.fsf@3c22fb11fdab.ant.amazon.com>
Injection-Date: Tue, 15 Feb 2022 16:30:55 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="2bde51fdd18c24d4fadc45b645fc7da3";
logging-data="28037"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18U5dTq2jOm2lmP1JT8BhOCeq9MO3QFJXU="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:mp1vKKUKuz3AoFm1piBcybZ1kNk=
 by: Kaz Kylheku - Tue, 15 Feb 2022 16:30 UTC

On 2022-02-15, Sam Steingold <sds@gnu.org> wrote:
>> * Stefan Monnier <zbaavre@veb.hzbagerny.pn> [2022-02-15 09:35:18 -0500]:
>>
>> Does someone know of an article or rationale explaining why `lambda` is
>> a macro, i.e. why the fully-expanded code needs to be (function (lambda
>> ...)) rather than just (lambda ...)?
>
> Speaking as an implementor, a macro is "cheaper" than a special
> operator, so _requiring_ something to be a special operator is a weird
> thing to do unless there is a compelling reason for that.

But you're already paying the cost anyway, because

(function (lambda (..) ...))

is a special form. And that has to exist; function is necessary because
of Lisp-2, and for consistency it is essential that lambda be
substitutable for name in (function name).

In light of that, you might not want two special forms; i.e.
that both (function (lambda (...) ...)) and (lambda (...) ...)
exist as special forms.

On the other hand, they can share most of their implementation.

When we are compiling (function ...) and see that the argument is
a lambda expression, we can just recurse into the lambda compiler
with that argument.

Still, there is a pressure to keep the special form count down, and it's
probably highly desirable in a standard.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: Why is `lambda` not a special form

<jwvmtisc6dr.fsf-monnier+comp.lang.lisp@gnu.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: monnier@iro.umontreal.ca (Stefan Monnier)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Tue, 15 Feb 2022 13:50:42 -0500
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <jwvmtisc6dr.fsf-monnier+comp.lang.lisp@gnu.org>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215080700.39@kylheku.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="f5eb5aba23f1f57d35d02e72b57d6302";
logging-data="21788"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+660pYaES22qJ+fQWdPC9q"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
Cancel-Lock: sha1:UDD6UPFPnEBKCezciRuC7cQcVHE=
sha1:9GkL5LjleIULRDd3cixMKvlmC2A=
 by: Stefan Monnier - Tue, 15 Feb 2022 18:50 UTC

> where it is a form, we still need a story which explains what lambda is in
>
> ((lambda (...) ...) ...)

Was it considered important to support this syntax? Why?

Stefan

Re: Why is `lambda` not a special form

<20220215111335.417@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 480-992-1380@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Tue, 15 Feb 2022 19:36:24 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <20220215111335.417@kylheku.com>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215080700.39@kylheku.com>
<jwvmtisc6dr.fsf-monnier+comp.lang.lisp@gnu.org>
Injection-Date: Tue, 15 Feb 2022 19:36:24 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="2bde51fdd18c24d4fadc45b645fc7da3";
logging-data="17840"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18p+/nfEucA6opapYDwQEOtloVG2YrTrZY="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:XWGq/copc/xDyky7irfjqSGOCcE=
 by: Kaz Kylheku - Tue, 15 Feb 2022 19:36 UTC

On 2022-02-15, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> where it is a form, we still need a story which explains what lambda is in
>>
>> ((lambda (...) ...) ...)
>
> Was it considered important to support this syntax? Why?

It's important for consistency. If a macro inserts a name into a form
like this:

`(,name ...)

it's nice if that doesn't break when name happens to be a lambda
expression. Ideally, lambda expression should be able to appear wherever
a function name can appear (in a way that makes sense; i.e. not when the
name is a binding being established or mutated.)

Immediately-called lambda is historically significant also, because it
provides a way of binding variables. The let construct came later, and
can be explained in terms of an immediately-applied anonymous function.
Almost needless to mention, such lambdas occur in lambda calculus.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: Why is `lambda` not a special form

<jwva6erc2u5.fsf-monnier+comp.lang.lisp@gnu.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: monnier@iro.umontreal.ca (Stefan Monnier)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Tue, 15 Feb 2022 15:14:15 -0500
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <jwva6erc2u5.fsf-monnier+comp.lang.lisp@gnu.org>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215080700.39@kylheku.com>
<jwvmtisc6dr.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215111335.417@kylheku.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="f5eb5aba23f1f57d35d02e72b57d6302";
logging-data="22537"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19mzbNgk5Uan6UdeUi8KMVW"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
Cancel-Lock: sha1:smSdIQcyCAY7fII2WT8SVUgkRp4=
sha1:UBaYCvexCT5Ue3iCn1AwvVqCLIg=
 by: Stefan Monnier - Tue, 15 Feb 2022 20:14 UTC

Kaz Kylheku [2022-02-15 19:36:24] wrote:
> On 2022-02-15, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>>> where it is a form, we still need a story which explains what lambda is in
>>> ((lambda (...) ...) ...)
>> Was it considered important to support this syntax? Why?
> It's important for consistency. If a macro inserts a name into a form
> like this:
>
> `(,name ...)
>
> it's nice if that doesn't break when name happens to be a lambda
> expression.

I wonder why/when such a thing would happen. If `lambda` is a special
form, then `name` would either hold a function value or a form (whose
evaluation will return a function value), neither of which would
naturally include function names. And those cases using `(funcall
',name ...) resp. `(funcall ,name ...) would make more sense.

IOW I think the above expectation is a result of the use of #' for
lambda, rather than the other way around.

> Ideally, lambda expression should be able to appear wherever
> a function name can appear

I wonder if such a desire was part of the motivation of this design
choice, tho.

> Immediately-called lambda is historically significant also, because it
> provides a way of binding variables. The let construct came later, and
> can be explained in terms of an immediately-applied anonymous function.
> Almost needless to mention, such lambdas occur in lambda calculus.

Yes, as I said, I can see good reasons why this appeared in Lisp's
history, but I'm interested to know why Common Lisp *kept* this design.
I haven't found any hint that it was a conscious decision, so maybe it's
just been kept because noone considered changing it.

Stefan

Re: Why is `lambda` not a special form

<suh28b$56k$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no_email@invalid.invalid (Zyni Moë)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Tue, 15 Feb 2022 20:25:47 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <suh28b$56k$1@dont-email.me>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 15 Feb 2022 20:25:47 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="6111ef778a916f2655704e7c422bed1a";
logging-data="5332"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19clAYrs5k9qRhhMPeCwio3EC9FIw6VqjQ="
User-Agent: NewsTap/5.5 (iPad)
Cancel-Lock: sha1:KQjrjZdiwIDS6eHjj7D2G8tWatQ=
sha1:g/7lHcqjb2BYeuHlBjPosNUOmFw=
 by: Zyni Moë - Tue, 15 Feb 2022 20:25 UTC

Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> Does someone know of an article or rationale explaining why `lambda` is
> a macro, i.e. why the fully-expanded code needs to be (function (lambda
> ...)) rather than just (lambda ...)?

Making it one increases the number of special operators and hence means
that every code walker needs to be modified to know about it. Not making
it one has no cost at all to anyone: any implementation which wants to
treat it as a special operator internally is entirely free to do so.

This is also why defining it as a macro was safe: code walkers already know
both how to expand macros and how to deal with FUNCTION forms.

--
the small snake

Re: Why is `lambda` not a special form

<suh2ge$6qo$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no_email@invalid.invalid (Zyni Moë)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Tue, 15 Feb 2022 20:30:06 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <suh2ge$6qo$1@dont-email.me>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215080700.39@kylheku.com>
<jwvmtisc6dr.fsf-monnier+comp.lang.lisp@gnu.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 15 Feb 2022 20:30:06 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="6111ef778a916f2655704e7c422bed1a";
logging-data="7000"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18mdP6oq8GWnPgfPwR6GIYJuCBp54k0hac="
User-Agent: NewsTap/5.5 (iPad)
Cancel-Lock: sha1:G/EvOzbB0xbJ9UNhKTXmvGwJsrE=
sha1:ThVYRuE4uRfzbjz4dkTzGFyjgBs=
 by: Zyni Moë - Tue, 15 Feb 2022 20:30 UTC

Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> Was it considered important to support this syntax? Why?
>

Because CL aimed to be compatible with earlier implementations in which
this syntax was legal because they wanted people not to have to rewrite
code for no possible useful purpose. Because people write macros which
expand to this. Because (x ...) in the default case expects x to be a
function name and (lambda () ...) is a function name.

--
the small snake

Re: Why is `lambda` not a special form

<20220215122049.254@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 480-992-1380@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Tue, 15 Feb 2022 20:36:47 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 93
Message-ID: <20220215122049.254@kylheku.com>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215080700.39@kylheku.com>
<jwvmtisc6dr.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215111335.417@kylheku.com>
<jwva6erc2u5.fsf-monnier+comp.lang.lisp@gnu.org>
Injection-Date: Tue, 15 Feb 2022 20:36:47 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="2bde51fdd18c24d4fadc45b645fc7da3";
logging-data="2587"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+4B6jP7Ia7WNfafTGjF783iMGUFgMYm1s="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:VYcfWLfmgpTYH8et1kklQmoI99A=
 by: Kaz Kylheku - Tue, 15 Feb 2022 20:36 UTC

On 2022-02-15, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> Kaz Kylheku [2022-02-15 19:36:24] wrote:
>> On 2022-02-15, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>>>> where it is a form, we still need a story which explains what lambda is in
>>>> ((lambda (...) ...) ...)
>>> Was it considered important to support this syntax? Why?
>> It's important for consistency. If a macro inserts a name into a form
>> like this:
>>
>> `(,name ...)
>>
>> it's nice if that doesn't break when name happens to be a lambda
>> expression.
>
> I wonder why/when such a thing would happen. If `lambda` is a special
> form, then `name` would either hold a function value or a form (whose
> evaluation will return a function value), neither of which would
> naturally include function names. And those cases using `(funcall
> ',name ...) resp. `(funcall ,name ...) would make more sense.

Well you need `(funcall (function ,name) ...)`. So now you're
superfluously including both pieces of Lisp-2 vebiage: funcall and
function.

If you know that the argument is a name, which it *must* be in order
to serve as an argument of the function operator, then you can just
generate `(,name ...); and if name can be lambda, then that is
a correct reduction of `(funcall (function ,name) ...)`.

>
> IOW I think the above expectation is a result of the use of #' for
> lambda, rather than the other way around.
>
>> Ideally, lambda expression should be able to appear wherever
>> a function name can appear
>
> I wonder if such a desire was part of the motivation of this design
> choice, tho.

It must have been; the Glossary even documents that a lambda expression
is: "n. a list which can be used in place of a function name in certain
contexts to denote a function by directly describing its behavior rather
than indirectly by referring to the name of an established function; its
name derives from the fact that its first element is the symbol lambda."

The main place where function names are used are in function calls,
so it would be an odd exception not to have lambda work in exactly
that "popular" spot.

The situation of being able to use a lambda instead of a function name
anywhere the function definition isn't being (re)defined is simpler
than such a situation, *plus* an arbitrary exception.

>> Immediately-called lambda is historically significant also, because it
>> provides a way of binding variables. The let construct came later, and
>> can be explained in terms of an immediately-applied anonymous function.
>> Almost needless to mention, such lambdas occur in lambda calculus.
>
> Yes, as I said, I can see good reasons why this appeared in Lisp's
> history, but I'm interested to know why Common Lisp *kept* this design.
> I haven't found any hint that it was a conscious decision, so maybe it's
> just been kept because noone considered changing it.

Old examples from old historic texts and books wouldn't work. If you
were teaching newcomers about how let related to lambda, you'd have to
always add, "Well, that's how LET originally related to lambda, but
Common Lisp got rid of that: you can't apply arguments directly to a
LAMBDA any more". Then you'd nee a time-wasting explanation for those
students who wanted to know why.

It would be critized as a quirk by the users of other languages.
How come you can write an anonymous function, but not just apply
arguments to it directly?

Speaking of other languages, in the abombination known as Javascript,
statements cannot return values. Only expressions, and function bodies,
via the return statement. If you want, say a switch to return a value,
you must write an immediately applied function:

val colorName = (function () {
switch (colorNum) {
// Of course, a dictionary object would
// actually be used for this specific situation.
case 0 : return "red";
case 1 : return "green";
case 2 : return "blue";
case 3 : return "unknown color";
}
})();

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: Why is `lambda` not a special form

<jwvee43aisf.fsf-monnier+comp.lang.lisp@gnu.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: monnier@iro.umontreal.ca (Stefan Monnier)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Tue, 15 Feb 2022 17:06:25 -0500
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <jwvee43aisf.fsf-monnier+comp.lang.lisp@gnu.org>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<suh28b$56k$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="f5eb5aba23f1f57d35d02e72b57d6302";
logging-data="3248"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18iZ2jt48yO/tRpH5EjdxZL"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
Cancel-Lock: sha1:nBOf2vZRVD7eCF09zJ0VIOhGz0Q=
sha1:AovG8NVD+zTl8LqRS0erLCJ2wZs=
 by: Stefan Monnier - Tue, 15 Feb 2022 22:06 UTC

Zyni Moë [2022-02-15 20:25:47] wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> Does someone know of an article or rationale explaining why `lambda` is
>> a macro, i.e. why the fully-expanded code needs to be (function (lambda
>> ...)) rather than just (lambda ...)?
> Making it one increases the number of special operators and hence means
> that every code walker needs to be modified to know about it.

I don't see the benefit: all code walkers need to know about (function
(lambda ...)) instead.

> This is also why defining it as a macro was safe: code walkers already know
> both how to expand macros and how to deal with FUNCTION forms.

If you presume that (function (lambda ...)) exists, of course it doesn't
make sense to define `lambda` as a special form, but my question is
rather about the choice between

(lambda ...)

and

(function (lambda ...))

-- Stefan

Re: Why is `lambda` not a special form

<jwv8rubaio9.fsf-monnier+comp.lang.lisp@gnu.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: monnier@iro.umontreal.ca (Stefan Monnier)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Tue, 15 Feb 2022 17:07:37 -0500
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <jwv8rubaio9.fsf-monnier+comp.lang.lisp@gnu.org>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215080700.39@kylheku.com>
<jwvmtisc6dr.fsf-monnier+comp.lang.lisp@gnu.org>
<suh2ge$6qo$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="f5eb5aba23f1f57d35d02e72b57d6302";
logging-data="3248"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+C21fzfmjEbGYzhAN8XH6z"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
Cancel-Lock: sha1:fz/7uAxrw2GXCAZmS4HG07iuLtQ=
sha1:/If9ihF8LrWFcxmj5DuWIAmGH2E=
 by: Stefan Monnier - Tue, 15 Feb 2022 22:07 UTC

Zyni Moë [2022-02-15 20:30:06] wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> Was it considered important to support this syntax? Why?
>
> Because CL aimed to be compatible with earlier implementations in which
> this syntax was legal because they wanted people not to have to rewrite
> code for no possible useful purpose. Because people write macros which
> expand to this. Because (x ...) in the default case expects x to be a
> function name and (lambda () ...) is a function name.

So the main motivation was backward compatibility?
That does sound very likely, indeed. Does someone have a pointer to
some document describing this decision?

Stefan

Re: Why is `lambda` not a special form

<jwv35kjaiju.fsf-monnier+comp.lang.lisp@gnu.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: monnier@iro.umontreal.ca (Stefan Monnier)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Tue, 15 Feb 2022 17:28:20 -0500
Organization: A noiseless patient Spider
Lines: 98
Message-ID: <jwv35kjaiju.fsf-monnier+comp.lang.lisp@gnu.org>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215080700.39@kylheku.com>
<jwvmtisc6dr.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215111335.417@kylheku.com>
<jwva6erc2u5.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215122049.254@kylheku.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="f5eb5aba23f1f57d35d02e72b57d6302";
logging-data="19318"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/9wXXq1HWOvs8qCkGYW5HA"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
Cancel-Lock: sha1:b1eJ/f/ukKgySKFPeJY7cBpjh3s=
sha1:qFTg49TBRlNySw0n3t1EXEhOwHI=
 by: Stefan Monnier - Tue, 15 Feb 2022 22:28 UTC

>> I wonder why/when such a thing would happen. If `lambda` is a special
>> form, then `name` would either hold a function value or a form (whose
>> evaluation will return a function value), neither of which would
>> naturally include function names. And those cases using `(funcall
>> ',name ...) resp. `(funcall ,name ...) would make more sense.
>
> Well you need `(funcall (function ,name) ...)`.

That's only if your argument is neither a function value nor a form
returning function value, but is instead a function name that should be
lexically resolved.

If it's a function value (or a function name that should be globally
resolved) you need `(funcall ',name ...) and if it's a form you need
`(funcall ,name ...).

I don't see why (other than force of habit and backward compatibility)
"a function name that should be lexically resolved" should include
lambda expressions.

> If you know that the argument is a name, which it *must* be in order
> to serve as an argument of the function operator,

That seems to presume you want lambda expression in your "namespace",
whereas what I'm asking is why should we presume that.

>>> Ideally, lambda expression should be able to appear wherever
>>> a function name can appear
>> I wonder if such a desire was part of the motivation of this design
>> choice, tho.
> It must have been; the Glossary even documents that a lambda expression
> is: "n. a list which can be used in place of a function name in certain
> contexts to denote a function by directly describing its behavior rather
> than indirectly by referring to the name of an established function; its
> name derives from the fact that its first element is the symbol lambda."

This documents the result of the design, not necessarily the rationale
for it, tho.

> The main place where function names are used are in function calls,
> so it would be an odd exception not to have lambda work in exactly
> that "popular" spot.

Would you really describe ((lambda ...) ...) as popular in Common Lisp?
[ In ELisp, it's very rare. ]

> The situation of being able to use a lambda instead of a function name
> anywhere the function definition isn't being (re)defined is simpler
> than such a situation, *plus* an arbitrary exception.

I'm not sure it's simpler overall. Instead the rule would be that all
forms are of the share (SYMBOL . ARGS) and that to refer to the function
value of a function name you use #' and that to call a function value
you use `funcall`. I don't see any arbitrary exception.

> Old examples from old historic texts and books wouldn't work. If you
> were teaching newcomers about how let related to lambda, you'd have to
> always add, "Well, that's how LET originally related to lambda, but
> Common Lisp got rid of that: you can't apply arguments directly to a
> LAMBDA any more".

You could still write

(funcall (lambda ...) ...)

which just makes the justification for introducing `let` more obvious.
[ Actually I do exactly that in my courses ;-) ]
And you don't need to bother telling your students that some earlier
versions of the language allowed a different syntax.

> Speaking of other languages, in the abombination known as Javascript,
> statements cannot return values. Only expressions, and function bodies,
> via the return statement. If you want, say a switch to return a value,
> you must write an immediately applied function:
>
> val colorName = (function () {
> switch (colorNum) {
> // Of course, a dictionary object would
> // actually be used for this specific situation.
> case 0 : return "red";
> case 1 : return "green";
> case 2 : return "blue";
> case 3 : return "unknown color";
> }
> })();

Luckily in Lisp you don't need such silly immediately-applied lambdas
because the rest of the language is more sane.

BTW, part of what prompted this question is that you can trivially
provide an alternative (my-lambda ...) via a macro but you can't so easily
provide an alternative #'(my-lambda ...).

So this #'(lambda ...) syntax looks to me like a bit of
.... an arbitrary exception?

Stefan

Re: Why is `lambda` not a special form

<m3ee4360sy.fsf@leonis4.robolove.meer.net>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: enometh@meer.net (Madhu)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Wed, 16 Feb 2022 07:16:21 +0530
Organization: Motzarella
Lines: 14
Message-ID: <m3ee4360sy.fsf@leonis4.robolove.meer.net>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215080700.39@kylheku.com>
<jwvmtisc6dr.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215111335.417@kylheku.com>
<jwva6erc2u5.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215122049.254@kylheku.com>
<jwv35kjaiju.fsf-monnier+comp.lang.lisp@gnu.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="3e3fc2b5e0beee7bc72719ed3fc50d24";
logging-data="10658"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+opmWI/SOhUSqV4RMSWywkC7NYRXzM6ug="
Cancel-Lock: sha1:6ivTzULCeOUc3cLqEdguwptyErY=
sha1:TxfNCrnSRFKudZhrSbfxBR46DpI=
 by: Madhu - Wed, 16 Feb 2022 01:46 UTC

* Stefan Monnier <jwv35kjaiju.fsf-monnier+comp.lang.lisp @gnu.org> :
Wrote on Tue, 15 Feb 2022 17:28:20 -0500:

> I'm not sure it's simpler overall. Instead the rule would be that all
> forms are of the share (SYMBOL . ARGS) and that to refer to the function
> value of a function name you use #' and that to call a function value
> you use `funcall`. I don't see any arbitrary exception.

I really detest all the source code changes that you check in to elisp
sources that change perfectly normal uses of (lambda () ...) to
#'(lambda () ) just to satisfy your perverted aesthetic.

Re: Why is `lambda` not a special form

<suij3j$dho$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no_email@invalid.invalid (Zyni Moë)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Wed, 16 Feb 2022 10:19:31 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <suij3j$dho$1@dont-email.me>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<suh28b$56k$1@dont-email.me>
<jwvee43aisf.fsf-monnier+comp.lang.lisp@gnu.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 16 Feb 2022 10:19:31 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="54e13aad1758c4185ce71dde4cb64a12";
logging-data="13880"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/8smdoq7mjyzS7JX8cvjmdeMyyXJV0Xj0="
User-Agent: NewsTap/5.5 (iPad)
Cancel-Lock: sha1:vw2Z9FpaLpHCCLHpsN2lJDYlZFw=
sha1:V4pSZORmd1dH/dXpseTKtnLin4o=
 by: Zyni Moë - Wed, 16 Feb 2022 10:19 UTC

Stefan Monnier <monnier@iro.umontreal.ca> wrote:

>
> I don't see the benefit: all code walkers need to know about (function
> (lambda ...)) instead.

Try to think, Already code walkers must know about this and they will
continue to need to know about it for ever because (function x) will always
continue to be valid code and x can be (lambda ...) because otherwise would
clearly be insane. Changing that would cause uncountable lossage because
it is 1975; there is much existing code. Adding lambda as a special
operator would mean code walkers would either need to be modified to know
about it, or would silently fail. Adding lambda as a macro means no user
code needs to change.

And the CL designers made the right choice because they were aware that a
world outside their heads existed.

--
the small snake

Re: Why is `lambda` not a special form

<suilav$416$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no_email@invalid.invalid (Zyni Moë)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Wed, 16 Feb 2022 10:57:35 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <suilav$416$1@dont-email.me>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215080700.39@kylheku.com>
<jwvmtisc6dr.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215111335.417@kylheku.com>
<jwva6erc2u5.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215122049.254@kylheku.com>
<jwv35kjaiju.fsf-monnier+comp.lang.lisp@gnu.org>
<m3ee4360sy.fsf@leonis4.robolove.meer.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 16 Feb 2022 10:57:35 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="54e13aad1758c4185ce71dde4cb64a12";
logging-data="4134"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ftkRPtW7AcJOiDkOkNfVowLz0ccO3r1Y="
User-Agent: NewsTap/5.5 (iPad)
Cancel-Lock: sha1:B8hvCdvnQx/xnf1KPJUdk9wbA5s=
sha1:2o6sfdeby4OM23B0hWoP395UllY=
 by: Zyni Moë - Wed, 16 Feb 2022 10:57 UTC

Madhu <enometh@meer.net> wrote:

> I really detest all the source code changes that you check in to elisp
> sources that change perfectly normal uses of (lambda () ...) to
> #'(lambda () ) just to satisfy your perverted aesthetic.
>

Oh no, he isn't is he? That is a really impressive level of braindamage.

--
the small snake

Re: Why is `lambda` not a special form

<suimat$mag$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no_email@invalid.invalid (Zyni Moë)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Wed, 16 Feb 2022 11:14:37 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <suimat$mag$1@dont-email.me>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215080700.39@kylheku.com>
<jwvmtisc6dr.fsf-monnier+comp.lang.lisp@gnu.org>
<suh2ge$6qo$1@dont-email.me>
<jwv8rubaio9.fsf-monnier+comp.lang.lisp@gnu.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 16 Feb 2022 11:14:37 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="54e13aad1758c4185ce71dde4cb64a12";
logging-data="22864"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/QosMmIb1AmwvY/9+RkG8/hhBTTUBU9Rw="
User-Agent: NewsTap/5.5 (iPad)
Cancel-Lock: sha1:qQhc9xzKazQzqq/7L9FjebR5VBg=
sha1:P9gtphPM9aZCCfR4wEDg/SvQCYM=
 by: Zyni Moë - Wed, 16 Feb 2022 11:14 UTC

Stefan Monnier <monnier@iro.umontreal.ca> wrote:

>
> So the main motivation was backward compatibility?
> That does sound very likely, indeed. Does someone have a pointer to
> some document describing this decision?

Clue is in the name: *Common* Lisp: CL was famously intended to unify
various existing dialects, mostly flavours of MACLISP, although also at
least in theory Interlisp (in fact of course not so much Interlisp). There
was lots of MACLISP and other code, that code needed to not be changed
gratuitously. I am surprised you were unaware of this.

Indeed some of the designers of CL also were involved in the design of
another Lisp-family language, and that language does rather famously not
have FUNCTION or need FUNCALL, and in that language LAMBDA is a special
operator. Because that language did not require to be compatible with
MACLISP &c (or even, often, with earlier versions of itself).

But there is another reason: (funcall x ...) is a shit syntax. People read
code left to right (or, perhaps, right to left if they are Hebrew or Arabic
speakers etc): the left edge of the code is the thing you see first when
browsing through code, and you want the things at the left edge to be the
most important. This is why some old message-passing object systems in
Lisp were horrid: if you casually read the code you see

(send ...)
....
(send ...)
(send ...)
...

And this conveys approximately zero information. And similarly

(funcall ...)
....
(funcall ...)
(funcall ...)
...

is shit. Put the interesting thing -- usually the function -- as far to
the left as you can. And this is what ((lambda (...) ...) ...) does.

--
the small snake

Re: Why is `lambda` not a special form

<jwvbkz76ia2.fsf-monnier+comp.lang.lisp@gnu.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: monnier@iro.umontreal.ca (Stefan Monnier)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Wed, 16 Feb 2022 08:42:56 -0500
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <jwvbkz76ia2.fsf-monnier+comp.lang.lisp@gnu.org>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215080700.39@kylheku.com>
<jwvmtisc6dr.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215111335.417@kylheku.com>
<jwva6erc2u5.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215122049.254@kylheku.com>
<jwv35kjaiju.fsf-monnier+comp.lang.lisp@gnu.org>
<m3ee4360sy.fsf@leonis4.robolove.meer.net>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="dfb3c3281c40380383c09ed5700c9736";
logging-data="3035"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19AqX8+tL8wVnEnvLNooSDH"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
Cancel-Lock: sha1:fTGnjWyLblPFLXY26YVmMtgB1xE=
sha1:BExbNp185Ol4RsvGM51yeqVVkQY=
 by: Stefan Monnier - Wed, 16 Feb 2022 13:42 UTC

> I really detest all the source code changes that you check in to elisp
> sources that change perfectly normal uses of (lambda () ...) to
> #'(lambda () ) just to satisfy your perverted aesthetic.

Care to point to an example of that?
I do a lot of gratuitous cosmetic changes to satisfy my perverted
aesthetic in ELisp, indeed, but I prefer (lambda ...) over #'(lambda ...)
so if I were to make such a change it would be by mistake.

Stefan

Re: Why is `lambda` not a special form

<jwv5ypf6i6k.fsf-monnier+comp.lang.lisp@gnu.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: monnier@iro.umontreal.ca (Stefan Monnier)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Wed, 16 Feb 2022 08:44:49 -0500
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <jwv5ypf6i6k.fsf-monnier+comp.lang.lisp@gnu.org>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<suh28b$56k$1@dont-email.me>
<jwvee43aisf.fsf-monnier+comp.lang.lisp@gnu.org>
<suij3j$dho$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="dfb3c3281c40380383c09ed5700c9736";
logging-data="3035"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18GCmpGAO1uvS2kKi6klwmF"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
Cancel-Lock: sha1:cRiT02w/9piG1RMRmeW+JAIQlb0=
sha1:PI6IZeIfCwLD2hbAIkMKxLi06iI=
 by: Stefan Monnier - Wed, 16 Feb 2022 13:44 UTC

Zyni Moë [2022-02-16 10:19:31] wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> I don't see the benefit: all code walkers need to know about (function
>> (lambda ...)) instead.
> Try to think, Already code walkers must know about this and they will
> continue to need to know about it for ever because (function x) will always
> continue to be valid code and x can be (lambda ...) because otherwise would
> clearly be insane.

Insane, definitely not. But, if I read between the lines you're arguing
that the motivation to not consider such a change was
backward compatibility.

I guess that makes sense, thanks,

Stefan

Re: Why is `lambda` not a special form

<jwvtucy6d9b.fsf-monnier+comp.lang.lisp@gnu.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: monnier@iro.umontreal.ca (Stefan Monnier)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Wed, 16 Feb 2022 10:34:35 -0500
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <jwvtucy6d9b.fsf-monnier+comp.lang.lisp@gnu.org>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215080700.39@kylheku.com>
<jwvmtisc6dr.fsf-monnier+comp.lang.lisp@gnu.org>
<suh2ge$6qo$1@dont-email.me>
<jwv8rubaio9.fsf-monnier+comp.lang.lisp@gnu.org>
<suimat$mag$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="78f761c51fcb7be8c116fec35f477bf1";
logging-data="16355"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX194jFlYStVg1zwpSc+naq1L"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
Cancel-Lock: sha1:7gTIQqnPDdeGHFhGvWGdd6sL32o=
sha1:j6u6oYaqavsEdMbvkeLZRVj6w7o=
 by: Stefan Monnier - Wed, 16 Feb 2022 15:34 UTC

> And this conveys approximately zero information. And similarly
>
> (funcall ...)
> ...
> (funcall ...)
> (funcall ...)
> ...
>
> is shit.

Can't argue with that. I do also prefer Lisp-1 ;-)

> Put the interesting thing -- usually the function -- as far to
> the left as you can. And this is what ((lambda (...) ...) ...) does.

Hmm... two problem here:
- this just replaces `funcall` with `lambda` as the first thing on the
left: hardly better.
- In my experience, ((lambda ...) ...) is *very* rarely used.

Stefan

Re: Why is `lambda` not a special form

<lzczjmolfr.fsf@3c22fb11fdab.ant.amazon.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: sds@gnu.org (Sam Steingold)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Wed, 16 Feb 2022 10:55:36 -0500
Organization: disorganization
Lines: 22
Message-ID: <lzczjmolfr.fsf@3c22fb11fdab.ant.amazon.com>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<lziltgnn5m.fsf@3c22fb11fdab.ant.amazon.com>
<jwvleycdsk6.fsf-monnier+comp.lang.lisp@gnu.org>
Reply-To: sds@gnu.org
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="05ccfd6cb303c77874f2326d367a6310";
logging-data="15853"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19P2zIkDkXGTT8m66NzvvBa"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin)
Cancel-Lock: sha1:a0CGjLMXfPS6mo24eZ/saTTv8Tg=
sha1:K3bLntFpV6guRab7gbJmSaM/ZmE=
Return-Receipt-To: sds@gnu.org
X-Disclaimer: You should not expect anyone to agree with me.
X-Attribution: Sam
 by: Sam Steingold - Wed, 16 Feb 2022 15:55 UTC

> * Stefan Monnier <zbaavre@veb.hzbagerny.pn> [2022-02-15 11:08:23 -0500]:
>
> Sam Steingold [2022-02-15 10:51:33] wrote:
>>> * Stefan Monnier <zbaavre@veb.hzbagerny.pn> [2022-02-15 09:35:18 -0500]:
>>> Does someone know of an article or rationale explaining why `lambda` is
>>> a macro, i.e. why the fully-expanded code needs to be (function (lambda
>>> ...)) rather than just (lambda ...)?
>> Speaking as an implementor, a macro is "cheaper" than a special
>> operator, so _requiring_ something to be a special operator is a weird
>> thing to do unless there is a compelling reason for that.
>
> But any Common Lisp implementation will need to have special handling of
> (function (lambda ...)) and I fail to see how it would be cheaper than
> moving that work to a (lambda ...) special form.

One has to handle (function (lambda ...)) anyway; why do the work twice?

--
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.2113
http://childpsy.net http://calmchildstories.com http://steingoldpsychology.com
https://mideasttruth.com https://www.peaceandtolerance.org/
I have been called worse. By better people.

Re: Why is `lambda` not a special form

<m3k0duepom.fsf@leonis4.robolove.meer.net>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: enometh@meer.net (Madhu)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Wed, 16 Feb 2022 22:04:01 +0530
Organization: Motzarella
Lines: 18
Message-ID: <m3k0duepom.fsf@leonis4.robolove.meer.net>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215080700.39@kylheku.com>
<jwvmtisc6dr.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215111335.417@kylheku.com>
<jwva6erc2u5.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215122049.254@kylheku.com>
<jwv35kjaiju.fsf-monnier+comp.lang.lisp@gnu.org>
<m3ee4360sy.fsf@leonis4.robolove.meer.net>
<jwvbkz76ia2.fsf-monnier+comp.lang.lisp@gnu.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="50149c837f1a5218843fed65fc9d5553";
logging-data="25095"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18SEsA4vWtiYS0y+0tMvMFdiXqefQgzUlU="
Cancel-Lock: sha1:MXVYB+cGwcDafMsJlmvjgUe5OjM=
sha1:93w40rjmnZDOYdCqe0H+NCIWT1s=
 by: Madhu - Wed, 16 Feb 2022 16:34 UTC

* Stefan Monnier <jwvbkz76ia2.fsf-monnier+comp.lang.lisp @gnu.org> :
Wrote on Wed, 16 Feb 2022 08:42:56 -0500:

>> I really detest all the source code changes that you check in to elisp
>> sources that change perfectly normal uses of (lambda () ...) to
>> #'(lambda () ) just to satisfy your perverted aesthetic.
>
> Care to point to an example of that?
> I do a lot of gratuitous cosmetic changes to satisfy my perverted
> aesthetic in ELisp, indeed, but I prefer (lambda ...) over #'(lambda ...)
> so if I were to make such a change it would be by mistake.

I sincerely apologize for the slander and false witness, I should've
checked before posting. Perhaps I was remembering something from long
ago, but there is really no excuse.

The changes in the code base in recent have indeed been towards removing
redundant #' from lambda. Mea culpa. and sorry for misleading zyni.

Re: Why is `lambda` not a special form

<20220216151852.215@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 480-992-1380@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Thu, 17 Feb 2022 09:16:21 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 247
Message-ID: <20220216151852.215@kylheku.com>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215080700.39@kylheku.com>
<jwvmtisc6dr.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215111335.417@kylheku.com>
<jwva6erc2u5.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215122049.254@kylheku.com>
<jwv35kjaiju.fsf-monnier+comp.lang.lisp@gnu.org>
Injection-Date: Thu, 17 Feb 2022 09:16:21 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="11c0b711985767bf0ea1edd8d6554a92";
logging-data="11059"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/YcZA96IgZA5t1UR2rpz1/ZGrzU0uj2Zg="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:E+9muv1wx9Y1tZCzyG9YHGS7ioc=
 by: Kaz Kylheku - Thu, 17 Feb 2022 09:16 UTC

On 2022-02-15, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>>> I wonder why/when such a thing would happen. If `lambda` is a special
>>> form, then `name` would either hold a function value or a form (whose
>>> evaluation will return a function value), neither of which would
>>> naturally include function names. And those cases using `(funcall
>>> ',name ...) resp. `(funcall ,name ...) would make more sense.
>>
>> Well you need `(funcall (function ,name) ...)`.
>
> That's only if your argument is neither a function value nor a form
> returning function value, but is instead a function name that should be
> lexically resolved.
>
> If it's a function value (or a function name that should be globally
> resolved) you need `(funcall ',name ...) and if it's a form you need
> `(funcall ,name ...).
>
> I don't see why (other than force of habit and backward compatibility)
> "a function name that should be lexically resolved" should include
> lambda expressions.
>
>> If you know that the argument is a name, which it *must* be in order
>> to serve as an argument of the function operator,
>
> That seems to presume you want lambda expression in your "namespace",
> whereas what I'm asking is why should we presume that.

Because I'm used to the idea that, in mathematics, a name like x can denote,
say, an integer. Likewise, a literal like 42 can denote an integer.

Both x and 42 are entities of the same kind, and in all situations where we
just reference the value, we can substitute one for the other.

(There are situations where x isn't referenced as a value, like

"let x be an an integer greater than 100"

here, we cannot say:

"let 42 be an integer greater than 100"

but in a formula where x is referenced, like x + y, we can be
justified in making a substitution to 42 + y.)

Anyway, likewise, a lambda is a function literal. So likewise, just
like in any situation where the integer x is refernced, I should be
able to specify a concrete integer like 42, wherever some function f
is referenced, I should be able to specify the lambda literal.

>>>> Ideally, lambda expression should be able to appear wherever
>>>> a function name can appear
>>> I wonder if such a desire was part of the motivation of this design
>>> choice, tho.
>> It must have been; the Glossary even documents that a lambda expression
>> is: "n. a list which can be used in place of a function name in certain
>> contexts to denote a function by directly describing its behavior rather
>> than indirectly by referring to the name of an established function; its
>> name derives from the fact that its first element is the symbol lambda."
>
> This documents the result of the design, not necessarily the rationale
> for it, tho.

That is true; rationales tend to be separately given. Like for ANSI C
1989, a separate Rationale was published.

>> The main place where function names are used are in function calls,
>> so it would be an odd exception not to have lambda work in exactly
>> that "popular" spot.
>
> Would you really describe ((lambda ...) ...) as popular in Common Lisp?
> [ In ELisp, it's very rare. ]

Well, the spot is popular not necessarily the lambda being there.

The lambda is just denotes the right kind of thing that fits into
that spot.

In TXR Lisp, a Lisp-2, (lambda ...) is a special form. For quite a long time,
((lambda ...) ...) did not work. But: consistently, neither did
(fun (lambda ...) ...)

>> The situation of being able to use a lambda instead of a function name
>> anywhere the function definition isn't being (re)defined is simpler
>> than such a situation, *plus* an arbitrary exception.
>
> I'm not sure it's simpler overall. Instead the rule would be that all
> forms are of the share (SYMBOL . ARGS) and that to refer to the function
> value of a function name you use #' and that to call a function value
> you use `funcall`. I don't see any arbitrary exception.

These definitions, by themselves, do not talk about anonymous functions
at all. So when those are introduced, it should be in some internally
consistent way.

>> Old examples from old historic texts and books wouldn't work. If you
>> were teaching newcomers about how let related to lambda, you'd have to
>> always add, "Well, that's how LET originally related to lambda, but
>> Common Lisp got rid of that: you can't apply arguments directly to a
>> LAMBDA any more".
>
> You could still write
>
> (funcall (lambda ...) ...)

Yes; you could introduce troduce lambda into the dialect as being a kind
of expression that, only under evaluation, produces a function,
and not something substitutable for function names.

I believe that for consistency, you should then also banish
(function (lambda ...))).

So either have lambdas that can be used almost everywhere where function
names can be used, and so ((lambda ...) ...) is possible as well
as #'(lambda ...). Or else, say no: lambdas are not expressions that can be
used in place of a function name but strictly evaluated expressions that
produce a a closure. Then, have neither ((lambda ...) ...) nor #'(lambda ...).

Either situation is simpler than an ad-hoc mixture: one works but not the other.

Arguably, CL would therefore be simpler without the lambda macro;
it's already conceptually consistent without it.

The CL lambda macro causes lambda expressions to do something which function
names cannot: appear in an evaluated context without any kind of quoting,
and produce a functional value.

> which just makes the justification for introducing `let` more obvious.
> [ Actually I do exactly that in my courses ;-) ]
> And you don't need to bother telling your students that some earlier
> versions of the language allowed a different syntax.

That's undoubtedly how education works in the world of Javascript
or Python and whatnot. History is important though, and it's a good
thing we have strong connections to it in the Lisp world.

> BTW, part of what prompted this question is that you can trivially
> provide an alternative (my-lambda ...) via a macro but you can't so easily
> provide an alternative #'(my-lambda ...).

Or an alternative ((my-lambda ...) ...)!

We can think about a mechanism which allows this, yet clings to Lisp-2
tooth and nail.

Suppose we introduce the concept of "function name macros". A function name
macro invocation occurs when a compound expression appears as a function
name that is not a lambda or setf.

((my-lambda ...) ...)

#'(my-lambda ...)

This could be defined with some new definer macro, e.g.:

(define-function-name-macro kons ()
'cons)

Now we can have:

((kons) 1 2) -> (cons 1 2) -> (1 . 2)

Furthermore, there can be a rule that when an expression is being
expanded in the ordinary evaluation context, then function name
macros are visible (with a low precedence: if kons is both a macro
and a function name macro, the macro wins). When a function name
macro is expanded in ordinary context, it is wrapped with the function
operator, either before or after expansion:

Then we can do

(funcall (kons) 1 2) -> (funcall (function (kons)) 1 2)

-> (funcall (function cons) 1 2) -> (1 . 2)

Partial application macro:

(define-function-name-macro kons (car-expr)
(let ((cdr (gensym)))
`(lambda (,cdr) (cons ,car-expr ,cdr))))

((kons 1) 2) -> (1 . 2)

(mapcar (kons 1) '(a b c)) -> ((1 . a) (1 . b) (1 . c))

(mapcar #'(kons 1) '(a b c)) -> ((1 . a) (1 . b) (1 . c))

> So this #'(lambda ...) syntax looks to me like a bit of
> ... an arbitrary exception?

Only the existence of the lambda macro makes it look that way, but
#'(lambda ...) is in the same category as ((lambda ..) ...) which is
consistent. You can't target either position with a macro because of Lisp-2;
ordinary macros are evaluated expressions, and inactive in a function name
context.

But Lisps can have macros in any space; macros /per se/ don't require an
evaluation context. For instance, a pattern matcher can allow new patterns to
be defined in terms of existing pattern operators by providing a defpattern
macro for defining them. That is basically a macro mechanism in the pattern
space.

The CL lambda macro creates an inconsistency in that it looks exactly like a
lambda expression, which can be used in the above two contexts; but any other
macro you define by any other name cannot be. (Which we could fix with the
function name macros idea.)

Incidentally, under the above function name macros, lambda could be defined as
a trivial, no-op function macro:

(define-function-name-macro lambda (&rest args &whole lambda-expr)
lambda-expr)


Click here to read the complete article
Re: Why is `lambda` not a special form

<jwv4k4x4jsg.fsf-monnier+comp.lang.lisp@gnu.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: monnier@iro.umontreal.ca (Stefan Monnier)
Newsgroups: comp.lang.lisp
Subject: Re: Why is `lambda` not a special form
Date: Thu, 17 Feb 2022 10:14:13 -0500
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <jwv4k4x4jsg.fsf-monnier+comp.lang.lisp@gnu.org>
References: <jwvr184dx1k.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215080700.39@kylheku.com>
<jwvmtisc6dr.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215111335.417@kylheku.com>
<jwva6erc2u5.fsf-monnier+comp.lang.lisp@gnu.org>
<20220215122049.254@kylheku.com>
<jwv35kjaiju.fsf-monnier+comp.lang.lisp@gnu.org>
<20220216151852.215@kylheku.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="bea98adecb175c81622af547f2dcb8a9";
logging-data="2167"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/WbwMTY4EmzFu6bf75mjIz"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
Cancel-Lock: sha1:bPwoyqb/nICIdTh4dO1r7Y1NiXQ=
sha1:zRpdvDCFju9CIqSKJEvxy876WRo=
 by: Stefan Monnier - Thu, 17 Feb 2022 15:14 UTC

> Anyway, likewise, a lambda is a function literal. So likewise, just
> like in any situation where the integer x is refernced, I should be
> able to specify a concrete integer like 42, wherever some function f
> is referenced, I should be able to specify the lambda literal.

That makes sense, indeed.
I wonder if that was part of the motivation in the decision back then.
Also, I'll note that AFAIK Common Lisp does not obey that reasoning when
it comes to macros :-(
And Scheme doesn't either, FWIW.

> I believe that for consistency, you should then also banish
> (function (lambda ...))).

Definitely, yes.

> So either have lambdas that can be used almost everywhere where function
> names can be used, and so ((lambda ...) ...) is possible as well
> as #'(lambda ...). Or else, say no: lambdas are not expressions that can be
> used in place of a function name but strictly evaluated expressions that
> produce a a closure. Then, have neither ((lambda ...) ...) nor #'(lambda ...).

100% agreed. I guess I thought it was obvious, so I didn't spell it out
in my original message :-(

>> BTW, part of what prompted this question is that you can trivially
>> provide an alternative (my-lambda ...) via a macro but you can't so easily
>> provide an alternative #'(my-lambda ...).
> Or an alternative ((my-lambda ...) ...)!

Right.

> Suppose we introduce the concept of "function name macros".

;-)

Stefan


devel / comp.lang.lisp / Why is `lambda` not a special form

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor