all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Robin Templeton <robin@terpri.org>,
	19790@debbugs.gnu.org, Lars Ingebrigtsen <larsi@gnus.org>,
	Stefan Monnier <monnier@iro.umontreal.ca>,
	Michael Heerdegen <michael_heerdegen@web.de>
Subject: bug#19790: [PATCH] destructive splicing in backquote
Date: Sat, 14 Sep 2019 14:31:21 +0200	[thread overview]
Message-ID: <CADwFkmn0=iyuuV0+==DTygK+TraRMzNgaYUivFXFPSNX+uRvGg@mail.gmail.com> (raw)
In-Reply-To: <83o8znz6ur.fsf@gnu.org>

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


  reply	other threads:[~2019-09-14 12:31 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 [this message]
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

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

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

  git send-email \
    --in-reply-to='CADwFkmn0=iyuuV0+==DTygK+TraRMzNgaYUivFXFPSNX+uRvGg@mail.gmail.com' \
    --to=stefan@marxist.se \
    --cc=19790@debbugs.gnu.org \
    --cc=eliz@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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.