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.
This commit is contained in:
Stefan Kangas 2019-09-14 01:49:23 +02:00
parent b94f01a616
commit 3cf8f9b1ec
4 changed files with 21 additions and 5 deletions

View file

@ -2005,6 +2005,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'.

View file

@ -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");

View file

@ -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--;

View file

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