unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Robin Templeton <robin@terpri.org>,
	19790@debbugs.gnu.org, Lars Ingebrigtsen <larsi@gnus.org>,
	Michael Heerdegen <michael_heerdegen@web.de>
Subject: bug#19790: [PATCH] destructive splicing in backquote
Date: Sun, 15 Sep 2019 16:57:57 +0200	[thread overview]
Message-ID: <CADwFkmk2Su2YRcUV4nghEzZcahbdHAxeS8wTu9wYKafoTgY-rw@mail.gmail.com> (raw)
In-Reply-To: <jwv5zlupjro.fsf-monnier+emacs@gnu.org>

[-- 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


  reply	other threads:[~2019-09-15 14:57 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2019-09-26 16:38         ` Stefan Kangas
2019-09-14 12:07   ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADwFkmk2Su2YRcUV4nghEzZcahbdHAxeS8wTu9wYKafoTgY-rw@mail.gmail.com \
    --to=stefan@marxist.se \
    --cc=19790@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=michael_heerdegen@web.de \
    --cc=monnier@iro.umontreal.ca \
    --cc=robin@terpri.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).