GNU bug report logs - #61281
“`(a \, b)” equals to “`(a . ,b)”

Previous Next

Package: emacs;

Reported by: Xie Shynur <one.last.kiss <at> outlook.com>

Date: Sat, 4 Feb 2023 23:29:02 UTC

Severity: normal

Full log


Message #38 received at 61281 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: Xie Shynur <one.last.kiss <at> outlook.com>,
 "61281 <at> debbugs.gnu.org" <61281 <at> debbugs.gnu.org>
Subject: Re: [External] : Re: bug#61281: “`(a \,
 b)” equals to “`(a . ,
 b)”
Date: Mon, 06 Feb 2023 00:56:00 +0100
Drew Adams <drew.adams <at> oracle.com> writes:

> Dunno.  (read ",foo") and (read ", foo" return
> (\, foo).  Why?  (Just because the current
> implementation of backquote depends on that?)

As I said: any other format would lead to the same "problem", no?
Unless ",X" is something "meta" that has no reader-construct-less
expansion at all.

> (read "'foo") returns just 'foo - it doesn't
> return (quote foo).  (read "`foo") returns
> `foo, not (backquote foo).  (read "`,foo")
> returns `,foo.

You forget that the printer is able to produce this format.  Try `car'.

> Notice the error msg from (eval ',foo):
>
> Debugger entered--Lisp error: (void-function \,)
>   ,foo
>   eval(,foo)
>   (progn (eval ',foo))
>
> Nothing in (normal) Lisp syntax shows the use
> of comma as a function.  ,foo doesn't look
> like function-call syntax, does it?

Another side effect of ,X being equivalent to (\, X.).  That's the only
thing you need to remember.  When you eval that, you should not be
surprised that it's evaluated like ... Lisp evaluates things.

> And here's the error from either (read ",")
> or (eval (read ",")):
>
>  End of file during parsing
>
> Yes, an error should be reported in each case,
> but I think it should just say that comma is
> undefined outside of backquote.

S-exps are defined recursively.  ",X" is read syntax of a valid s-exp,
and I don't think we want to make the reader raise an error for it.  But
the reader expects an expression following the ",".  And a single "," is
_not_the read syntax of the symbol with the name "," (that is "\,":
(symbol-name (read "\\,")) --> ",").

So "End of file during parsing" is an appropriate message: no complete
expression could be read, but something that looks like the start of an
expression.


Ok, so everything is about that you don't want that ,X and (\, X) are
equivalent.  All your arguments were of the kind "the implications are
surprising".  But you never answered the core question: what should ,X
expand to instead that would not have any of these implications?  Else
all you say is that it's surprising when you lack knowledge.


OTOH it seems not easy to find the information ,X == (\, X) somewhere.
Is there a place where there is said something about the kind of
expression the reader construct ,X produces?  I didn't find anything in
a rush.  It should be explained, else this thing indeed can lead to
surprises, as the one reported here.

Michael.




This bug report was last modified 2 years and 127 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.