GNU bug report logs - #64537
mix lists and vectors when using backquote

Previous Next

Package: emacs;

Reported by: Shynur Xie <one.last.kiss <at> outlook.com>

Date: Sun, 9 Jul 2023 05:46:01 UTC

Severity: normal

To reply to this bug, email your comments to 64537 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#64537; Package emacs. (Sun, 09 Jul 2023 05:46:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Shynur Xie <one.last.kiss <at> outlook.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 09 Jul 2023 05:46:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Shynur Xie <one.last.kiss <at> outlook.com>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: mix lists and vectors when using backquote
Date: Sun, 9 Jul 2023 05:40:46 +0000
The docstring of ‘backquote’ says “vectors work just like lists”.
Should we also clarify that mixing lists and vectors these 2 way:

    `(... ,@[...])  ; by contrast: `(,@[] 1)  => (1)
    `[,@'()]        ; by contrast: `[1 ,@'()] => [1]

will lead to unexpected behavior?  Or suggest not doing so?  Or let
‘backquote’ detect this and signal an error?

BTW, if [[https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64415]] is
actually not a bug, please consider document that behavior.  Thanks.



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64537; Package emacs. (Fri, 22 Sep 2023 09:09:02 GMT) Full text and rfc822 format available.

Message #8 received at 64537 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Shynur Xie <one.last.kiss <at> outlook.com>
Cc: 64537 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#64537: mix lists and vectors when using backquote
Date: Fri, 22 Sep 2023 02:08:23 -0700
Shynur Xie <one.last.kiss <at> outlook.com> writes:

> The docstring of ‘backquote’ says “vectors work just like lists”.
> Should we also clarify that mixing lists and vectors these 2 way:
>
>     `(... ,@[...])  ; by contrast: `(,@[] 1)  => (1)
>     `[,@'()]        ; by contrast: `[1 ,@'()] => [1]
>
> will lead to unexpected behavior?  Or suggest not doing so?  Or let
> ‘backquote’ detect this and signal an error?

Copying in Stefan Monnier.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64537; Package emacs. (Fri, 22 Sep 2023 15:06:02 GMT) Full text and rfc822 format available.

Message #11 received at 64537 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 64537 <at> debbugs.gnu.org, Shynur Xie <one.last.kiss <at> outlook.com>
Subject: Re: bug#64537: mix lists and vectors when using backquote
Date: Fri, 22 Sep 2023 11:03:31 -0400
>> The docstring of ‘backquote’ says “vectors work just like lists”.
>> Should we also clarify that mixing lists and vectors these 2 way:
>>
>>     `(... ,@[...])  ; by contrast: `(,@[] 1)  => (1)
>>     `[,@'()]        ; by contrast: `[1 ,@'()] => [1]
>>
>> will lead to unexpected behavior?  Or suggest not doing so?  Or let
>> ‘backquote’ detect this and signal an error?
>
> Copying in Stefan Monnier.

Is there a good reason why we have those unexpected behaviors?


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64537; Package emacs. (Sun, 24 Sep 2023 09:48:01 GMT) Full text and rfc822 format available.

Message #14 received at 64537 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 64537 <at> debbugs.gnu.org, Shynur Xie <one.last.kiss <at> outlook.com>
Subject: Re: bug#64537: mix lists and vectors when using backquote
Date: Sun, 24 Sep 2023 02:47:22 -0700
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>>> The docstring of ‘backquote’ says “vectors work just like lists”.
>>> Should we also clarify that mixing lists and vectors these 2 way:
>>>
>>>     `(... ,@[...])  ; by contrast: `(,@[] 1)  => (1)
>>>     `[,@'()]        ; by contrast: `[1 ,@'()] => [1]
>>>
>>> will lead to unexpected behavior?  Or suggest not doing so?  Or let
>>> ‘backquote’ detect this and signal an error?
>>
>> Copying in Stefan Monnier.
>
> Is there a good reason why we have those unexpected behaviors?

I see two unexpected behaviors:

  1.   `(... ,@[...])  =>  (\... . [\...])
  2.   `[,@'()]        =>  [(\,@ 'nil)]

I'd say these are the expected values:

  1.   `(... ,@[...])  =>  (\... \...)
  2.   `[,@'()]        =>  []

I don't see any good reason for them, so perhaps these are just plain
bugs to be fixed?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64537; Package emacs. (Sat, 08 Jun 2024 23:56:01 GMT) Full text and rfc822 format available.

Message #17 received at 64537 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Shynur Xie <one.last.kiss <at> outlook.com>
Cc: 64537 <at> debbugs.gnu.org
Subject: Re: bug#64537: mix lists and vectors when using backquote
Date: Sat, 08 Jun 2024 19:45:45 -0400
>     `(... ,@[...])  ; by contrast: `(,@[] 1)  => (1)

AFAICT this is the result of an optimization:

    `(BAR ,@FOO)

is optimized to

    `(BAR . ,FOO)

I expect a fair bit of code "relies" on this optimization, so I'm not
sure we want to "fix" it.

>     `[,@'()]        ; by contrast: `[1 ,@'()] => [1]

This looks like a plain bug (probably linked to another optimization).

    `[,@(not t)]

doesn't suffer from this problem but

    `[,@'[]]

also suffers from it.


        Stefan





This bug report was last modified 1 year and 6 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.