Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Research is what I'm doing when I don't know what I'm doing. -- Wernher von Braun


devel / comp.lang.lisp / Re: sharing &rest macro lambda lists - conformance question

SubjectAuthor
* sharing &rest macro lambda lists - conformance questionMadhu
`* Re: sharing &rest macro lambda lists - conformance questionSpiros Bousbouras
 `- Re: sharing &rest macro lambda lists - conformance questionMadhu

1
sharing &rest macro lambda lists - conformance question

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

  copy mid

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

  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: sharing &rest macro lambda lists - conformance question
Date: Sun, 20 Mar 2022 14:33:46 +0530
Organization: Motzarella
Lines: 43
Message-ID: <m3o8213si5.fsf@leonis4.robolove.meer.net>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="6509f198594196e8079a683731934988";
logging-data="27444"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+fp4D/nkIi3/qatifi2wFpZFVYERSJCm8="
Cancel-Lock: sha1:3Bo6biN6DfGq6Rye+rY3VJHEzMg=
sha1:JXFlSKjjqu97ePtvXcY6UkPPnt4=
 by: Madhu - Sun, 20 Mar 2022 09:03 UTC

consider a hypothetical macro BARF which destructively modifies its
&rest list - it rotates the first two arguments in place:

#+begin_src lisp
(defmacro barf (&rest list)
"rotates the first two arguments to produce a list"
(let ((a (car list))
(b (cadr list)))
(setf (car list) b (cadr list) a)
`(list ,@list)))

(macroexpand-1 '(barf 1 2)) ; => (list 2 1)

(defmacro cowf ()
`(let ((a 1) (b 2) (c 3) (d 4))
(barf a b c d)))

(macroexpand-1 '(cowf)) ; =>
;; => (LET ((A 1) (B 2) (C 3) (D 4)) (BARF A B C D)), T

(cowf) ;; => (2 1 3 4)

(macroexpand-1 '(cowf)) =>
;; (LET ((A 1) (B 2) (C 3) (D 4))
;; (BARF B A C D))

;; i.e. executing COWF changes the macrofunction to toggle between
;; calling (BARF A B C D) and (BARF B A C D)
#+end_src

Clearly BARF should be written functionally so it doesn't mutate the
&rest lambda list.

But is this issue (of &rest lambda lists) written up anywhere? Has it
been discussed on cll before? Doesn't this behaviour of the compiler on
DEFMACRO have to be specified? Are there any problems in required it to
cons up a new &rest list for each expansion?

Only allegro seems to implement the last behaviour, which I think
is the desired behaviour

Re: sharing &rest macro lambda lists - conformance question

<tVe7JBPzk+ZwEkDjT@bongo-ra.co>

  copy mid

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

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.lisp
Subject: Re: sharing &rest macro lambda lists - conformance question
Date: Sun, 20 Mar 2022 11:24:40 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <tVe7JBPzk+ZwEkDjT@bongo-ra.co>
References: <m3o8213si5.fsf@leonis4.robolove.meer.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 20 Mar 2022 11:24:40 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="51b7d5b6e45a9c7aa1784773c4b429c0";
logging-data="25849"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19mdLJwQSXZhOVbH+GAdakA"
Cancel-Lock: sha1:wblLvXweqwdFW00VEa5DHOr95WI=
In-Reply-To: <m3o8213si5.fsf@leonis4.robolove.meer.net>
X-Organisation: Weyland-Yutani
X-Server-Commands: nowebcancel
 by: Spiros Bousbouras - Sun, 20 Mar 2022 11:24 UTC

On Sun, 20 Mar 2022 14:33:46 +0530
Madhu <enometh@meer.net> wrote:
>
> consider a hypothetical macro BARF which destructively modifies its
> &rest list - it rotates the first two arguments in place:
>
> #+begin_src lisp
> (defmacro barf (&rest list)
> "rotates the first two arguments to produce a list"
> (let ((a (car list))
> (b (cadr list)))
> (setf (car list) b (cadr list) a)
> `(list ,@list)))
>
> (macroexpand-1 '(barf 1 2)) ; => (list 2 1)
>
> (defmacro cowf ()
> `(let ((a 1) (b 2) (c 3) (d 4))
> (barf a b c d)))
>
> (macroexpand-1 '(cowf)) ; =>
> ;; => (LET ((A 1) (B 2) (C 3) (D 4)) (BARF A B C D)), T
>
> (cowf) ;; => (2 1 3 4)
>
> (macroexpand-1 '(cowf)) =>
> ;; (LET ((A 1) (B 2) (C 3) (D 4))
> ;; (BARF B A C D))
>
> ;; i.e. executing COWF changes the macrofunction to toggle between
> ;; calling (BARF A B C D) and (BARF B A C D)
> #+end_src
>
> Clearly BARF should be written functionally so it doesn't mutate the
> &rest lambda list.
>
> But is this issue (of &rest lambda lists) written up anywhere?

3.1.2.1.2.2 Macro Forms
The consequences are undefined if a macro function destructively
modifies any part of its form argument.

> Has it
> been discussed on cll before? Doesn't this behaviour of the compiler on
> DEFMACRO have to be specified?

I don't think that CLHS tends to specify such esoteric implementation details
and for good reason. If you want a fresh &rest list you can trivially
create one so why should the CLHS specify anything ?

> Are there any problems in required it to
> cons up a new &rest list for each expansion?

It's not a good idea for a standard to specify implementation details.

> Only allegro seems to implement the last behaviour, which I think
> is the desired behaviour

--
CALAMARI WRESTLER is basically a "boxing movie", and follows most of the
conventions of the genre... with the exception of species.
https://www.imdb.com/review/rw1419366/

Re: sharing &rest macro lambda lists - conformance question

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

  copy mid

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

  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: sharing &rest macro lambda lists - conformance question
Date: Sun, 20 Mar 2022 17:26:51 +0530
Organization: Motzarella
Lines: 24
Message-ID: <m3a6dk4z24.fsf@leonis4.robolove.meer.net>
References: <m3o8213si5.fsf@leonis4.robolove.meer.net>
<tVe7JBPzk+ZwEkDjT@bongo-ra.co>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="a4dbf773b0c50f2db1355453856e0d97";
logging-data="1271"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+w1j/W5ex+JqsulJRJbOWt5rlvWSf/nw="
Cancel-Lock: sha1:nG/Atgx3yRhLANhC/5rGrMs7xuM=
sha1:MItmb6HJGfXM+p+GrYvLkidO5jQ=
 by: Madhu - Sun, 20 Mar 2022 11:56 UTC

* Spiros Bousbouras <tVe7JBPzk+ZwEkDjT@bongo-ra.co> :
Wrote on Sun, 20 Mar 2022 11:24:40 -0000 (UTC):
>> Clearly BARF should be written functionally so it doesn't mutate the
>> &rest lambda list.
>> But is this issue (of &rest lambda lists) written up anywhere?
>
> 3.1.2.1.2.2 Macro Forms
> The consequences are undefined if a macro function destructively
> modifies any part of its form argument.

Thanks. I knew I was missing a spot.

>> Has it been discussed on cll before? Doesn't this behaviour of the
>> compiler on DEFMACRO have to be specified?
> I don't think that CLHS tends to specify such esoteric implementation
> details and for good reason. If you want a fresh &rest list you can
> trivially create one so why should the CLHS specify anything ?
>> Are there any problems in required it to cons up a new &rest list for
>> each expansion?
> It's not a good idea for a standard to specify implementation details.

Yes of course, but this particular thing would make the macro form have
the same meaning as it would have if it were not part of a macro.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor