* bug#19790: [PATCH] destructive splicing in backquote
@ 2015-02-06 6:39 Robin Templeton
2015-02-06 15:29 ` Stefan Monnier
` (2 more replies)
0 siblings, 3 replies; 20+ messages in thread
From: Robin Templeton @ 2015-02-06 6:39 UTC (permalink / raw)
To: 19790
Common Lisp and MACLISP define comma-dot syntax for destructive splicing
in backquote expressions. The Elisp reader reads ",.x" as "(\,\. x)"
(like ",@"), but the resulting forms are not processed by the backquote
library. A patch follows that adds CL-compatible comma-dot support.
Originally reported by at Artur Malabarba in
<http://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00624.html>.
-- >8 --
Subject: [PATCH] destructive splicing in backquote
Allow Common Lisp-compatible destructive splicing in backquote
expressions using ",." syntax.
* lisp/emacs-lisp/backquote.el (backquote-destructive-splice-symbol):
New variable.
(backquote-process): Allow backquote-destructive-splice-symbol as a
synonym for backquote-splice-symbol.
---
lisp/ChangeLog | 7 +++++++
lisp/emacs-lisp/backquote.el | 6 +++++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c18a8ff..fd643ed 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
+2015-02-06 Robin Templeton <robin@terpri.org>
+
+ * emacs-lisp/backquote.el (backquote-destructive-splice-symbol):
+ New variable.
+ (backquote-process): Allow backquote-destructive-splice-symbol as
+ a synonym for backquote-splice-symbol.
+
2015-02-03 Artur Malabarba <bruce.connor.am@gmail.com>
* emacs-lisp/package.el (package-delete): Document NOSAVE.
diff --git a/lisp/emacs-lisp/backquote.el b/lisp/emacs-lisp/backquote.el
index d5cdca2..b6e1792 100644
--- a/lisp/emacs-lisp/backquote.el
+++ b/lisp/emacs-lisp/backquote.el
@@ -90,6 +90,9 @@ For example (backquote-list* 'a 'b 'c) => (a b . c)"
(defconst backquote-splice-symbol '\,@
"Symbol used to represent a splice inside a backquote.")
+(defconst backquote-destructive-splice-symbol '\,.
+ "Symbol used to represent a destructive splice inside a backquote.")
+
(defmacro backquote (structure)
"Argument STRUCTURE describes a template to build.
@@ -160,7 +163,8 @@ LEVEL is only used internally and indicates the nesting level:
(t (cons (if (eq (car-safe (nth 1 s)) 'quote) 0 1)
(nth 1 s))))
(backquote-delay-process s (1- level))))
- ((eq (car s) backquote-splice-symbol)
+ ((or (eq (car s) backquote-splice-symbol)
+ (eq (car s) backquote-destructive-splice-symbol))
(if (<= level 0)
(if (> (length s) 2)
;; (cons 2 `(append . ,(cdr s)))
--
2.1.4
^ permalink raw reply related [flat|nested] 20+ messages in thread
* bug#19790: [PATCH] destructive splicing in backquote
2015-02-06 6:39 bug#19790: [PATCH] destructive splicing in backquote Robin Templeton
@ 2015-02-06 15:29 ` Stefan Monnier
2015-02-07 18:51 ` Robin Templeton
2016-02-23 11:08 ` Lars Ingebrigtsen
2019-09-13 23:59 ` Stefan Kangas
2 siblings, 1 reply; 20+ messages in thread
From: Stefan Monnier @ 2015-02-06 15:29 UTC (permalink / raw)
To: Robin Templeton; +Cc: 19790
> library. A patch follows that adds CL-compatible comma-dot support.
Other than CL-compatibility, what is the use of this?
Stefan
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#19790: [PATCH] destructive splicing in backquote
2015-02-06 15:29 ` Stefan Monnier
@ 2015-02-07 18:51 ` Robin Templeton
2015-02-07 21:46 ` Robin Templeton
0 siblings, 1 reply; 20+ messages in thread
From: Robin Templeton @ 2015-02-07 18:51 UTC (permalink / raw)
To: 19790
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>> library. A patch follows that adds CL-compatible comma-dot support.
>
> Other than CL-compatibility, what is the use of this?
It's an improvement over having the feature half-implemented, as it is
now. Read syntax for comma-dot was added in 1995 (commit
176348460d640ae96b0b21567df0de1457aa962b) without corresponding support
in backquote.el, and it has only been mentioned online a few times since
then, so it seemed harmless to implement what was likely originally
intended.
--
Inteligenta persono lernas la lingvon Esperanton rapide kaj facile.
Esperanto estas moderna, kultura lingvo por la mondo. Simpla, fleksebla,
belsona, Esperanto estas la praktika solvo de la problemo de universala
interkompreno. Lernu la interlingvon Esperanton!
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#19790: [PATCH] destructive splicing in backquote
2015-02-07 18:51 ` Robin Templeton
@ 2015-02-07 21:46 ` Robin Templeton
2015-02-08 19:23 ` Stefan Monnier
0 siblings, 1 reply; 20+ messages in thread
From: Robin Templeton @ 2015-02-07 21:46 UTC (permalink / raw)
To: 19790
Robin Templeton <robin@terpri.org> writes:
> Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>
>>> library. A patch follows that adds CL-compatible comma-dot support.
>>
>> Other than CL-compatibility, what is the use of this?
>
> It's an improvement over having the feature half-implemented, as it is
> now. Read syntax for comma-dot was added in 1995 (commit
> 176348460d640ae96b0b21567df0de1457aa962b) without corresponding support
> in backquote.el, and it has only been mentioned online a few times since
> then, so it seemed harmless to implement what was likely originally
> intended.
Also, I could submit a patch to remove the special handling for ",." or
make it a syntax error, if either of those options would be preferable.
But the current behavior seems to be a bug.
--
Inteligenta persono lernas la lingvon Esperanton rapide kaj facile.
Esperanto estas moderna, kultura lingvo por la mondo. Simpla, fleksebla,
belsona, Esperanto estas la praktika solvo de la problemo de universala
interkompreno. Lernu la interlingvon Esperanton!
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#19790: [PATCH] destructive splicing in backquote
2015-02-07 21:46 ` Robin Templeton
@ 2015-02-08 19:23 ` Stefan Monnier
2015-02-08 19:38 ` Artur Malabarba
0 siblings, 1 reply; 20+ messages in thread
From: Stefan Monnier @ 2015-02-08 19:23 UTC (permalink / raw)
To: Robin Templeton; +Cc: 19790, Artur Malabarba
> Also, I could submit a patch to remove the special handling for ",." or
> make it a syntax error, if either of those options would be preferable.
> But the current behavior seems to be a bug.
Hmm... indeed recently Artur bumped into this (he uses identifiers
starting with "." and was surprised that ,<ident> didn't work in that
case).
Maybe removing this special syntax is the best option. Tho at least the
current situation leaves both choices still open ;-)
Stefan
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#19790: [PATCH] destructive splicing in backquote
2015-02-08 19:23 ` Stefan Monnier
@ 2015-02-08 19:38 ` Artur Malabarba
2015-02-09 3:10 ` Stefan Monnier
0 siblings, 1 reply; 20+ messages in thread
From: Artur Malabarba @ 2015-02-08 19:38 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Robin Templeton, 19790
Yes, I was surprised mostly for being caught of guard. :-)
After all this years I had never heard of ",." doing anything.
I agree that the current behavior is a bug, but either way we go is
fine for me (I managed to get around this limitation by simply adding
a space between the comma and the dot).
I'm fine with using this syntax for destructive splicing or with
disabling it altogether. But I think aliasing it to ",@" might be a
little deceptive for people who actually expect destructive splicing.
2015-02-08 17:23 GMT-02:00 Stefan Monnier <monnier@iro.umontreal.ca>:
>> Also, I could submit a patch to remove the special handling for ",." or
>> make it a syntax error, if either of those options would be preferable.
>> But the current behavior seems to be a bug.
>
> Hmm... indeed recently Artur bumped into this (he uses identifiers
> starting with "." and was surprised that ,<ident> didn't work in that
> case).
>
> Maybe removing this special syntax is the best option. Tho at least the
> current situation leaves both choices still open ;-)
>
>
> Stefan
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#19790: [PATCH] destructive splicing in backquote
2015-02-08 19:38 ` Artur Malabarba
@ 2015-02-09 3:10 ` Stefan Monnier
2015-02-09 13:03 ` Artur Malabarba
0 siblings, 1 reply; 20+ messages in thread
From: Stefan Monnier @ 2015-02-09 3:10 UTC (permalink / raw)
To: Artur Malabarba; +Cc: Robin Templeton, 19790
> I'm fine with using this syntax for destructive splicing or with
> disabling it altogether. But I think aliasing it to ",@" might be a
> little deceptive for people who actually expect destructive splicing.
There's never been a guarantee that it would use destructive splicing
(it's just allowed to), and I generally dislike destructive operations,
so I'd rather not go through extra trouble to support what I tend to see
as a misfeature.
So aliasing ,. to ,@ is OK, but making it work destructively is not.
Stefan
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#19790: [PATCH] destructive splicing in backquote
2015-02-09 3:10 ` Stefan Monnier
@ 2015-02-09 13:03 ` Artur Malabarba
0 siblings, 0 replies; 20+ messages in thread
From: Artur Malabarba @ 2015-02-09 13:03 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Robin Templeton, 19790
> There's never been a guarantee that it would use destructive splicing
> (it's just allowed to),
Then I'd vote for just removing it.
Still, this whole thing is corner-case enough that any solution is fine with me.
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#19790: [PATCH] destructive splicing in backquote
2015-02-06 6:39 bug#19790: [PATCH] destructive splicing in backquote Robin Templeton
2015-02-06 15:29 ` Stefan Monnier
@ 2016-02-23 11:08 ` Lars Ingebrigtsen
2019-06-25 17:59 ` Lars Ingebrigtsen
2019-09-13 23:59 ` Stefan Kangas
2 siblings, 1 reply; 20+ messages in thread
From: Lars Ingebrigtsen @ 2016-02-23 11:08 UTC (permalink / raw)
To: Robin Templeton; +Cc: 19790
Robin Templeton <robin@terpri.org> writes:
> Common Lisp and MACLISP define comma-dot syntax for destructive splicing
> in backquote expressions. The Elisp reader reads ",.x" as "(\,\. x)"
> (like ",@"), but the resulting forms are not processed by the backquote
> library. A patch follows that adds CL-compatible comma-dot support.
>
> Originally reported by at Artur Malabarba in
> <http://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00624.html>.
I think the conclusion to the discussion was that we do not want to
support the ,. operation in Emacs Lisp.
(setq .foo 1)
`((,.foo))
=> (((\,\. foo)))
So we should remove this feature completely, because that's obviously a
bug...
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#19790: [PATCH] destructive splicing in backquote
2016-02-23 11:08 ` Lars Ingebrigtsen
@ 2019-06-25 17:59 ` Lars Ingebrigtsen
2019-06-25 22:52 ` Michael Heerdegen
0 siblings, 1 reply; 20+ messages in thread
From: Lars Ingebrigtsen @ 2019-06-25 17:59 UTC (permalink / raw)
To: Robin Templeton; +Cc: 19790
Lars Ingebrigtsen <larsi@gnus.org> writes:
> Robin Templeton <robin@terpri.org> writes:
>
>> Common Lisp and MACLISP define comma-dot syntax for destructive splicing
>> in backquote expressions. The Elisp reader reads ",.x" as "(\,\. x)"
>> (like ",@"), but the resulting forms are not processed by the backquote
>> library. A patch follows that adds CL-compatible comma-dot support.
>>
>> Originally reported by at Artur Malabarba in
>> <http://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00624.html>.
>
> I think the conclusion to the discussion was that we do not want to
> support the ,. operation in Emacs Lisp.
>
> (setq .foo 1)
>
> `((,.foo))
> => (((\,\. foo)))
>
> So we should remove this feature completely, because that's obviously a
> bug...
It still is. Anybody object to removing it? And where is it even
defined?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#19790: [PATCH] destructive splicing in backquote
2019-06-25 17:59 ` Lars Ingebrigtsen
@ 2019-06-25 22:52 ` Michael Heerdegen
0 siblings, 0 replies; 20+ messages in thread
From: Michael Heerdegen @ 2019-06-25 22:52 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: Robin Templeton, 19790
Lars Ingebrigtsen <larsi@gnus.org> writes:
> And where is it even defined?
lread.c? (search for ",." and "comma_dot"). Dunno if there are more
places.
Michael.
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#19790: [PATCH] destructive splicing in backquote
2015-02-06 6:39 bug#19790: [PATCH] destructive splicing in backquote Robin Templeton
2015-02-06 15:29 ` Stefan Monnier
2016-02-23 11:08 ` Lars Ingebrigtsen
@ 2019-09-13 23:59 ` Stefan Kangas
2019-09-14 7:15 ` Eli Zaretskii
2019-09-14 12:07 ` Lars Ingebrigtsen
2 siblings, 2 replies; 20+ messages in thread
From: Stefan Kangas @ 2019-09-13 23:59 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: Robin Templeton, 19790, Michael Heerdegen
[-- Attachment #1: Type: text/plain, Size: 957 bytes --]
Lars Ingebrigtsen <larsi@gnus.org> writes:
> Robin Templeton <robin@terpri.org> writes:
>
>> Common Lisp and MACLISP define comma-dot syntax for destructive splicing
>> in backquote expressions. The Elisp reader reads ",.x" as "(\,\. x)"
>> (like ",@"), but the resulting forms are not processed by the backquote
>> library. A patch follows that adds CL-compatible comma-dot support.
>>
>> Originally reported by at Artur Malabarba in
>> <http://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00624.html>.
>
> I think the conclusion to the discussion was that we do not want to
> support the ,. operation in Emacs Lisp.
>
> (setq .foo 1)
>
> `((,.foo))
> => (((\,\. foo)))
>
> So we should remove this feature completely, because that's obviously a
> bug...
Thanks to Michael Heerdegen's pointers, I could come up with a patch.
Would something like the attached do the job? It simply removes this
feature and adds a test.
Best regards,
Stefan Kangas
[-- Attachment #2: 0001-Remove-support-for-destructive-splicing-in-elisp.patch --]
[-- Type: text/x-patch, Size: 2584 bytes --]
From 6ec6c69242fdae2e8c3745e722aa6068c3366ba3 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Sat, 14 Sep 2019 01:49:23 +0200
Subject: [PATCH] Remove support for destructive splicing in elisp
* src/lread.c (read1): Don't handle destructive splicing in
backquote expressions (e.g. ",.<identifier>"). (Bug#19790)
(syms_of_lread): Remove Qcomma_dot.
* src/print.c (print_object): Don't check for Qcomma_dot.
* test/src/eval-tests.el
(eval-tests-19790-backquote-comma-dot-substitution): New test.
---
src/lread.c | 3 ---
src/print.c | 3 +--
test/src/eval-tests.el | 7 +++++++
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/lread.c b/src/lread.c
index 6ae7a0d8ba..0551376aa6 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3307,8 +3307,6 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
if (ch == '@')
comma_type = Qcomma_at;
- else if (ch == '.')
- comma_type = Qcomma_dot;
else
{
if (ch >= 0) UNREAD (ch);
@@ -5080,7 +5078,6 @@ syms_of_lread (void)
DEFSYM (Qbackquote, "`");
DEFSYM (Qcomma, ",");
DEFSYM (Qcomma_at, ",@");
- DEFSYM (Qcomma_dot, ",.");
DEFSYM (Qinhibit_file_name_operation, "inhibit-file-name-operation");
DEFSYM (Qascii_character, "ascii-character");
diff --git a/src/print.c b/src/print.c
index 7c3da68fc9..bb013e282d 100644
--- a/src/print.c
+++ b/src/print.c
@@ -2086,8 +2086,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
else if (print_quoted && CONSP (XCDR (obj)) && NILP (XCDR (XCDR (obj)))
&& new_backquote_output
&& (EQ (XCAR (obj), Qcomma)
- || EQ (XCAR (obj), Qcomma_at)
- || EQ (XCAR (obj), Qcomma_dot)))
+ || EQ (XCAR (obj), Qcomma_at)))
{
print_object (XCAR (obj), printcharfun, false);
new_backquote_output--;
diff --git a/test/src/eval-tests.el b/test/src/eval-tests.el
index 48295b81fa..7a8eae82cf 100644
--- a/test/src/eval-tests.el
+++ b/test/src/eval-tests.el
@@ -169,4 +169,11 @@ eval-tests-33014-redefine
"Remove the Lisp reference to the byte-compiled object."
(setf (symbol-function #'eval-tests-33014-func) nil))
+(defun eval-tests-19790-backquote-comma-dot-substitution ()
+ "Regression test for Bug#19790.
+Don't handle destructive splicing in backquote expressions (like
+in Common Lisp). Instead, make sure substitution in backquote
+expressions works for identifiers starting with period."
+ (should (equal (let ((.x 'identity)) (eval `(,.x 'ok))) 'ok)))
+
;;; eval-tests.el ends here
--
2.20.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* bug#19790: [PATCH] destructive splicing in backquote
2019-09-13 23:59 ` Stefan Kangas
@ 2019-09-14 7:15 ` Eli Zaretskii
2019-09-14 12:31 ` Stefan Kangas
2019-09-15 1:46 ` Stefan Monnier
2019-09-14 12:07 ` Lars Ingebrigtsen
1 sibling, 2 replies; 20+ messages in thread
From: Eli Zaretskii @ 2019-09-14 7:15 UTC (permalink / raw)
To: Stefan Kangas, Stefan Monnier; +Cc: robin, 19790, larsi, michael_heerdegen
> From: Stefan Kangas <stefan@marxist.se>
> Date: Sat, 14 Sep 2019 01:59:30 +0200
> Cc: Robin Templeton <robin@terpri.org>, 19790@debbugs.gnu.org,
> Michael Heerdegen <michael_heerdegen@web.de>
>
> > I think the conclusion to the discussion was that we do not want to
> > support the ,. operation in Emacs Lisp.
> >
> > (setq .foo 1)
> >
> > `((,.foo))
> > => (((\,\. foo)))
> >
> > So we should remove this feature completely, because that's obviously a
> > bug...
>
> Thanks to Michael Heerdegen's pointers, I could come up with a patch.
> Would something like the attached do the job? It simply removes this
> feature and adds a test.
Adding Stefan who was involved in the discussion back then.
I have no opinion about the change, but I think this should be in
NEWS.
Thanks.
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#19790: [PATCH] destructive splicing in backquote
2019-09-13 23:59 ` Stefan Kangas
2019-09-14 7:15 ` Eli Zaretskii
@ 2019-09-14 12:07 ` Lars Ingebrigtsen
1 sibling, 0 replies; 20+ messages in thread
From: Lars Ingebrigtsen @ 2019-09-14 12:07 UTC (permalink / raw)
To: Stefan Kangas; +Cc: Robin Templeton, 19790, Michael Heerdegen
Stefan Kangas <stefan@marxist.se> writes:
> Thanks to Michael Heerdegen's pointers, I could come up with a patch.
> Would something like the attached do the job? It simply removes this
> feature and adds a test.
Looks good to me. I wonder whether there's a way to search to see
whether anybody in the wild has ever used the ,. construct, but I guess
that'd be pretty difficult.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#19790: [PATCH] destructive splicing in backquote
2019-09-14 7:15 ` Eli Zaretskii
@ 2019-09-14 12:31 ` Stefan Kangas
2019-09-14 13:30 ` Eli Zaretskii
2019-09-15 1:46 ` Stefan Monnier
1 sibling, 1 reply; 20+ messages in thread
From: Stefan Kangas @ 2019-09-14 12:31 UTC (permalink / raw)
To: Eli Zaretskii
Cc: Robin Templeton, 19790, Lars Ingebrigtsen, Stefan Monnier,
Michael Heerdegen
[-- Attachment #1: Type: text/plain, Size: 209 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
> I have no opinion about the change, but I think this should be in
> NEWS.
Thanks, I have attached a new patch with a suggested NEWS entry.
Best regards,
Stefan Kangas
[-- Attachment #2: 0001-Remove-support-for-destructive-splicing-in-elisp.patch --]
[-- Type: text/x-patch, Size: 3400 bytes --]
From a2d2cf693a9d0253c6afc4e144523e2a3b890492 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Sat, 14 Sep 2019 01:49:23 +0200
Subject: [PATCH] Remove support for destructive splicing in elisp
* src/lread.c (read1): Don't handle destructive splicing in
backquote expressions (e.g. ",.<identifier>"). (Bug#19790)
(syms_of_lread): Remove Qcomma_dot.
* src/print.c (print_object): Don't check for Qcomma_dot.
* test/src/eval-tests.el
(eval-tests-19790-backquote-comma-dot-substitution): New test.
* etc/NEWS: Announce it.
---
etc/NEWS | 13 +++++++++++++
src/lread.c | 3 ---
src/print.c | 3 +--
test/src/eval-tests.el | 7 +++++++
4 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 1bde9c442b..cc349abe2f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2092,6 +2092,19 @@ valid event type.
\f
* Lisp Changes in Emacs 27.1
+---
+** Incomplete destructive splicing support has been removed.
+Support for Common Lisp style destructive splicing (",.") was
+incomplete and broken for a long time. It has now been removed.
+
+This means that backquote substitution now works for identifiers
+starting with a period ("."). Consider the following example:
+
+ (let ((.foo 42)) `,.foo)
+
+In the past, this would have incorrectly evaluated to '(\,\. foo)',
+but will now instead evaluate to '42'.
+
+++
** The new 'quit-window-hook' is now run first when executing the
'quit-window' command.
diff --git a/src/lread.c b/src/lread.c
index 6ae7a0d8ba..0551376aa6 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3307,8 +3307,6 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
if (ch == '@')
comma_type = Qcomma_at;
- else if (ch == '.')
- comma_type = Qcomma_dot;
else
{
if (ch >= 0) UNREAD (ch);
@@ -5080,7 +5078,6 @@ syms_of_lread (void)
DEFSYM (Qbackquote, "`");
DEFSYM (Qcomma, ",");
DEFSYM (Qcomma_at, ",@");
- DEFSYM (Qcomma_dot, ",.");
DEFSYM (Qinhibit_file_name_operation, "inhibit-file-name-operation");
DEFSYM (Qascii_character, "ascii-character");
diff --git a/src/print.c b/src/print.c
index 7c3da68fc9..bb013e282d 100644
--- a/src/print.c
+++ b/src/print.c
@@ -2086,8 +2086,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
else if (print_quoted && CONSP (XCDR (obj)) && NILP (XCDR (XCDR (obj)))
&& new_backquote_output
&& (EQ (XCAR (obj), Qcomma)
- || EQ (XCAR (obj), Qcomma_at)
- || EQ (XCAR (obj), Qcomma_dot)))
+ || EQ (XCAR (obj), Qcomma_at)))
{
print_object (XCAR (obj), printcharfun, false);
new_backquote_output--;
diff --git a/test/src/eval-tests.el b/test/src/eval-tests.el
index 48295b81fa..7a8eae82cf 100644
--- a/test/src/eval-tests.el
+++ b/test/src/eval-tests.el
@@ -169,4 +169,11 @@ eval-tests-33014-redefine
"Remove the Lisp reference to the byte-compiled object."
(setf (symbol-function #'eval-tests-33014-func) nil))
+(defun eval-tests-19790-backquote-comma-dot-substitution ()
+ "Regression test for Bug#19790.
+Don't handle destructive splicing in backquote expressions (like
+in Common Lisp). Instead, make sure substitution in backquote
+expressions works for identifiers starting with period."
+ (should (equal (let ((.x 'identity)) (eval `(,.x 'ok))) 'ok)))
+
;;; eval-tests.el ends here
--
2.20.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* bug#19790: [PATCH] destructive splicing in backquote
2019-09-14 12:31 ` Stefan Kangas
@ 2019-09-14 13:30 ` Eli Zaretskii
2019-09-15 14:55 ` Stefan Kangas
0 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2019-09-14 13:30 UTC (permalink / raw)
To: Stefan Kangas; +Cc: robin, 19790, larsi, monnier, michael_heerdegen
> From: Stefan Kangas <stefan@marxist.se>
> Date: Sat, 14 Sep 2019 14:31:21 +0200
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>, Lars Ingebrigtsen <larsi@gnus.org>,
> Robin Templeton <robin@terpri.org>, 19790@debbugs.gnu.org,
> Michael Heerdegen <michael_heerdegen@web.de>
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> > I have no opinion about the change, but I think this should be in
> > NEWS.
>
> Thanks, I have attached a new patch with a suggested NEWS entry.
Looks OK, but I think the entry should be moved to the "Incompatible
changes" part.
Thanks.
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#19790: [PATCH] destructive splicing in backquote
2019-09-14 7:15 ` Eli Zaretskii
2019-09-14 12:31 ` Stefan Kangas
@ 2019-09-15 1:46 ` Stefan Monnier
2019-09-15 14:57 ` Stefan Kangas
1 sibling, 1 reply; 20+ messages in thread
From: Stefan Monnier @ 2019-09-15 1:46 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: robin, 19790, larsi, Stefan Kangas, michael_heerdegen
> Adding Stefan who was involved in the discussion back then.
LGTM.
> I have no opinion about the change, but I think this should be in NEWS.
Indeed,
Stefan
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#19790: [PATCH] destructive splicing in backquote
2019-09-14 13:30 ` Eli Zaretskii
@ 2019-09-15 14:55 ` Stefan Kangas
0 siblings, 0 replies; 20+ messages in thread
From: Stefan Kangas @ 2019-09-15 14:55 UTC (permalink / raw)
To: Eli Zaretskii
Cc: Robin Templeton, 19790, Lars Ingebrigtsen, Stefan Monnier,
Michael Heerdegen
Eli Zaretskii <eliz@gnu.org> writes:
> Looks OK, but I think the entry should be moved to the "Incompatible
> changes" part.
OK, I'll move it there.
^ permalink raw reply [flat|nested] 20+ messages in thread
* bug#19790: [PATCH] destructive splicing in backquote
2019-09-15 1:46 ` Stefan Monnier
@ 2019-09-15 14:57 ` Stefan Kangas
2019-09-26 16:38 ` Stefan Kangas
0 siblings, 1 reply; 20+ messages in thread
From: Stefan Kangas @ 2019-09-15 14:57 UTC (permalink / raw)
To: Stefan Monnier
Cc: Robin Templeton, 19790, Lars Ingebrigtsen, Michael Heerdegen
[-- Attachment #1: Type: text/plain, Size: 238 bytes --]
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> > Adding Stefan who was involved in the discussion back then.
>
> LGTM.
Thanks. If there are no further comments, I'll commit the attached in
a few days.
Best regards,
Stefan Kangas
[-- Attachment #2: 0001-Remove-support-for-destructive-splicing-in-elisp.patch --]
[-- Type: text/x-patch, Size: 3485 bytes --]
From 700e7d23ecca2cd741d68ccc379e60596858c004 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Sat, 14 Sep 2019 01:49:23 +0200
Subject: [PATCH] Remove support for destructive splicing in elisp
* src/lread.c (read1): Don't handle destructive splicing in
backquote expressions (e.g. ",.<identifier>"). (Bug#19790)
(syms_of_lread): Remove Qcomma_dot.
* src/print.c (print_object): Don't check for Qcomma_dot.
* test/src/eval-tests.el
(eval-tests-19790-backquote-comma-dot-substitution): New test.
* etc/NEWS: Announce it.
---
etc/NEWS | 13 +++++++++++++
src/lread.c | 3 ---
src/print.c | 3 +--
test/src/eval-tests.el | 7 +++++++
4 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 1bde9c442b..3eaccb7ac0 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1941,6 +1941,19 @@ immediately. Type 'M-x so-long-commentary' for full documentation.
\f
* Incompatible Lisp Changes in Emacs 27.1
+---
+** Incomplete destructive splicing support has been removed.
+Support for Common Lisp style destructive splicing (",.") was
+incomplete and broken for a long time. It has now been removed.
+
+This means that backquote substitution now works for identifiers
+starting with a period ("."). Consider the following example:
+
+ (let ((.foo 42)) `,.foo)
+
+In the past, this would have incorrectly evaluated to '(\,\. foo)',
+but will now instead evaluate to '42'.
+
---
** The REGEXP in 'magic-mode-alist' is now matched case-sensitively.
Likewise for 'magic-fallback-mode-alist'.
diff --git a/src/lread.c b/src/lread.c
index 6ae7a0d8ba..0551376aa6 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3307,8 +3307,6 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
if (ch == '@')
comma_type = Qcomma_at;
- else if (ch == '.')
- comma_type = Qcomma_dot;
else
{
if (ch >= 0) UNREAD (ch);
@@ -5080,7 +5078,6 @@ syms_of_lread (void)
DEFSYM (Qbackquote, "`");
DEFSYM (Qcomma, ",");
DEFSYM (Qcomma_at, ",@");
- DEFSYM (Qcomma_dot, ",.");
DEFSYM (Qinhibit_file_name_operation, "inhibit-file-name-operation");
DEFSYM (Qascii_character, "ascii-character");
diff --git a/src/print.c b/src/print.c
index 7c3da68fc9..bb013e282d 100644
--- a/src/print.c
+++ b/src/print.c
@@ -2086,8 +2086,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
else if (print_quoted && CONSP (XCDR (obj)) && NILP (XCDR (XCDR (obj)))
&& new_backquote_output
&& (EQ (XCAR (obj), Qcomma)
- || EQ (XCAR (obj), Qcomma_at)
- || EQ (XCAR (obj), Qcomma_dot)))
+ || EQ (XCAR (obj), Qcomma_at)))
{
print_object (XCAR (obj), printcharfun, false);
new_backquote_output--;
diff --git a/test/src/eval-tests.el b/test/src/eval-tests.el
index 48295b81fa..7a8eae82cf 100644
--- a/test/src/eval-tests.el
+++ b/test/src/eval-tests.el
@@ -169,4 +169,11 @@ eval-tests-33014-redefine
"Remove the Lisp reference to the byte-compiled object."
(setf (symbol-function #'eval-tests-33014-func) nil))
+(defun eval-tests-19790-backquote-comma-dot-substitution ()
+ "Regression test for Bug#19790.
+Don't handle destructive splicing in backquote expressions (like
+in Common Lisp). Instead, make sure substitution in backquote
+expressions works for identifiers starting with period."
+ (should (equal (let ((.x 'identity)) (eval `(,.x 'ok))) 'ok)))
+
;;; eval-tests.el ends here
--
2.20.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* bug#19790: [PATCH] destructive splicing in backquote
2019-09-15 14:57 ` Stefan Kangas
@ 2019-09-26 16:38 ` Stefan Kangas
0 siblings, 0 replies; 20+ messages in thread
From: Stefan Kangas @ 2019-09-26 16:38 UTC (permalink / raw)
To: Stefan Monnier
Cc: Robin Templeton, Michael Heerdegen, 19790-done, Lars Ingebrigtsen
Stefan Kangas <stefan@marxist.se> writes:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
> > LGTM.
>
> Thanks. If there are no further comments, I'll commit the attached in
> a few days.
No more comments in 11 days, so I've now pushed this to master as
commit 3cf8f9b1ec. I'm consequently closing this bug.
Best regards,
Stefan Kangas
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2019-09-26 16:38 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-06 6:39 bug#19790: [PATCH] destructive splicing in backquote Robin Templeton
2015-02-06 15:29 ` Stefan Monnier
2015-02-07 18:51 ` Robin Templeton
2015-02-07 21:46 ` Robin Templeton
2015-02-08 19:23 ` Stefan Monnier
2015-02-08 19:38 ` Artur Malabarba
2015-02-09 3:10 ` Stefan Monnier
2015-02-09 13:03 ` Artur Malabarba
2016-02-23 11:08 ` Lars Ingebrigtsen
2019-06-25 17:59 ` Lars Ingebrigtsen
2019-06-25 22:52 ` Michael Heerdegen
2019-09-13 23:59 ` Stefan Kangas
2019-09-14 7:15 ` Eli Zaretskii
2019-09-14 12:31 ` Stefan Kangas
2019-09-14 13:30 ` Eli Zaretskii
2019-09-15 14:55 ` Stefan Kangas
2019-09-15 1:46 ` Stefan Monnier
2019-09-15 14:57 ` Stefan Kangas
2019-09-26 16:38 ` Stefan Kangas
2019-09-14 12:07 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).