all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Robin Templeton <robin@terpri.org>,
	19790@debbugs.gnu.org,
	Michael Heerdegen <michael_heerdegen@web.de>
Subject: bug#19790: [PATCH] destructive splicing in backquote
Date: Sat, 14 Sep 2019 01:59:30 +0200	[thread overview]
Message-ID: <CADwFkmm-QOu_GiXmfLvmpEZ2C0hwFJTqkGKbj1HxuYeJo8thng@mail.gmail.com> (raw)
In-Reply-To: <87a90r35o9.fsf@panthera.terpri.org>

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


  parent reply	other threads:[~2019-09-13 23:59 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 [this message]
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

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=CADwFkmm-QOu_GiXmfLvmpEZ2C0hwFJTqkGKbj1HxuYeJo8thng@mail.gmail.com \
    --to=stefan@marxist.se \
    --cc=19790@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=michael_heerdegen@web.de \
    --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.