emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 3cf8f9b: Remove support for destructive splicing in


From: Stefan Kangas
Subject: [Emacs-diffs] master 3cf8f9b: Remove support for destructive splicing in elisp
Date: Thu, 26 Sep 2019 12:37:52 -0400 (EDT)

branch: master
commit 3cf8f9b1ec1a079f6cd1a127259414dcb0cf8672
Author: Stefan Kangas <address@hidden>
Commit: Stefan Kangas <address@hidden>

    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 0939443..0a4ada3 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2006,6 +2006,19 @@ immediately.  Type 'M-x so-long-commentary' for full 
documentation.
 * 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 151731a..5000b38 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3310,8 +3310,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 @@ this variable will become obsolete.  */);
   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 7e5aed8..77ddd93 100644
--- a/src/print.c
+++ b/src/print.c
@@ -2076,8 +2076,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 48295b8..7a8eae8 100644
--- a/test/src/eval-tests.el
+++ b/test/src/eval-tests.el
@@ -169,4 +169,11 @@ are found on the stack and therefore not garbage 
collected."
   "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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]