bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#61281: “`(a \, b)” equals to “`(a . , b)”


From: Drew Adams
Subject: bug#61281: “`(a \, b)” equals to “`(a . , b)”
Date: Mon, 6 Feb 2023 03:49:03 +0000

> > And the question is about "\,", not ",".
> >
> > (setq ,X  42) ; => 42
> > (setq \,X 42) ; => (wrong-type-argument symbolp (\, X))
> 
> The other way round.

Yes, I accidentally reversed the comments.  Thx.

> "\,X" is interpreted as symbol, just as "\,".

Yes, backslash escapes the special meaning of
comma -- but only outside backquote.

Unescaped comma by itself is not interpreted as
a symbol inside backquote or outside it.

And leaving aside the X:

(setq ,  42)  ; => (wrong-number-of-arguments setq 1)
              ;    from expansion to (setq (\, 42))
(setq \, 42)  ; => 42

Comma is special in raising an error outside
backquote.  But there, escaping it makes it
just symbol syntax.  Not so inside backquote:
there, escaping it has no effect -- "\," and
"," behave the same inside backquote.

> What's the question about "\,"?

Why is it equivalent to "," inside backquote?

> > (I'd be interested in what the case is in Common
> > Lisp, including what a typical implementation is.)
> 
> AFAIU, there are different implementations.  I tested two random CL and
> two random scheme interpreters.  Of those 4, 3 expanded
> ,X --> (unquote X), and in one case ,X was read as an atomic expression.

Sorry, I don't know what that means.  How is
"\," syntax treated inside backquote in those
interpreters?

If different CLs have different behavior in this
regard, then I wonder what the spec says about it
(if anything).  I didn't notice anything.

> > The question is whether \, and , should have the
> > same behavior.  Certainly \z and z have the same
> > behavior.  But character z has no special behavior
> > inside a backquote.
> 
> I think the necessity to escape the comma to get the symbol has been
> introduced to avoid ambiguities with uses of the reader macro.

Not sure what you mean.  I'd think it's to give
you a way to use comma in a symbol name.  Same as
for the other chars you need to escape for that,
such as "(".

Escaping a comma outside backquote works, to give
you symbol syntax, but that doesn't work inside
backquote?  Why doesn't it?  I don't mean "why" in
terms of "how so".  I mean why _should_ that be
the case?  Is there a good reason for this behavior
(in terms of useful behavior, not in terms of
implementation)?  I don't see any, so far.

> > \@ and @ don't have the same behavior inside a
> > backquote.  And neither do \. and . -- only \,
> > and , have the same behavior.
> >
> > To me, that's just an implementation/design
> > thing, not something normal or inevitable.
> > Not a big deal, not the end of the world.
> > [A] minor unfortunate thing (gotcha).
> 
> In any case, much too late to change it.
> 
> > I pointed to the comments in the code.  They tell the story.  But I
> > don't think there's any such explanation/description in the doc.
> 
> Yes, it would be good to add something.

Glad we agree on something. ;-)





reply via email to

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