emacs-devel
[Top][All Lists]
Advanced

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

RE: Why "symbol's value" error about a list?


From: Drew Adams
Subject: RE: Why "symbol's value" error about a list?
Date: Mon, 5 Feb 2018 13:46:38 -0800 (PST)

> >   > For example, suppose you have a Lisp program that produces the
> >   > following error message when compiled/executed:
> >   >   Symbol's value as variable is void: 'аbbrevs-changed
> 
> > Does that error message really happen?  If so, how can I reproduce it?
> 
> In Emacs-25.3 -Q, do M-: (message "(setq foo 'bar)") RET
> followed by getting the output from *Messages* into the kill ring with
> M-w, followed by M-: C-y RET.
> 
> You might think you are executing (setq foo 'bar).  You're not.
> You're executing (setq foo ’bar), where the ’ is a Unicode curly quote.
> 
> The error message given out is:
>     Symbol's value as variable is void: ’bar

That was the old, and legitimate, error message, yes.  It
accurately describes what is really going on (as you describe
well, below).

Now the message is instead (invalid-read-syntax "strange quote"
"’").  Is that better?  That's part of what this discussion is
about.

I suggested that the variable name be enclosed in `...'.  That
would make the original message clearer, I think:

  Symbol's value as variable is void: `’bar'

At least it could make it more likely that you would think about
looking at that quote mark.

> This is a result of the change in `message', silently to convert ' to a
> curly quote, by default.  Some of us were unhappy at this change and
> protested against it.

Count me as one of those "some of us".  Echoing Lisp code
should do just that - no fiddling to "prettify" apostrophe to
curly quote etc.

> > Suppose it were 'foobaz', all ASCII, and we got an error such as
> >   Symbol's value as variable is void: 'foobaz
> > That still seems wrong.

Here's the thing: There _is_ a Lisp error - no doubt.

But for Lisp the error is not that a curly quote was read
as part of a symbol name.  That's not a Lisp error (at
least it has not been, until now.)

The error is using a symbol as a variable, when it is not
defined as a variable.  Which is exactly what the original
error message said.

That's the LISP error.  Is there a _user error_ here?
Yes, it's the mistake of copying and pasting what was
printed in *Messages*.

That user mistake is excusable.  And we would want to
inform the user about it, if we can't prevent it.  But
changing Lisp read syntax to guess what might be the
most helpful thing to tell a user here is NOT the solution.

Should this Lisp syntax change be reverted?  That's the
question being discussed here.

Changing the read syntax is a general, Lisp-level change.
We should instead prevent this user mistake by removing
its cause.

The real error here is (IMO) a design error by Emacs: The
expression read and copied to *Messages* should not have
been "helpfully" translated to use a curly quote instead
of an apostrophe.

Emacs shot Lisp in the foot on this one.  It's not the
fault of Lisp and its reader (syntax).  It's the fault of
some misguided "modernization" of Emacs gone amuck.  Users
should not find the input (setq foo 'bar) transformed to
(setq foo ’bar), i.e., APOSTROPHE replaced by RIGHT SINGLE
QUOTATION MARK.

> Again "’foobaz", not "foobaz" is the symbol, here.

Yes, and that's a legitimate symbol name.  Nothing wrong
with Lisp telling us that that symbol is undefined as a
variable.  That's exactly what the _LISP_ problem is here.

That's just not the symbol that was passed to Lisp
originally.  That's a non-variable symbol name copied from
*Messages*.  The mistake was putting that in *Messages* in
the first place.

Where was the mistake?  Lisp claiming that you used a
symbol as an undefined variable?  The user copying that
symbol name from *Messages* and trying to evaluate its
symbol as a var?  Or Emacs inserting a different symbol
name in *Messages*, by substituting the text "’bar" for
the text "'bar"?

The original Lisp expression was a Lisp expression, not
just text.  A quote mark (apostrophe) in Lisp has special
meaning, special syntax.  That shouldn't be ignored by
some dumb (yes) substitution of curly quotes for straight
quotes.

> > If the error was that foobaz was void, the error message
> > should not include a quote.  It should say
> >   Symbol's value as variable is void: foobaz
> 
> Yes.

No.  Only if `foobaz' were indeed the symbol that was an
undefined variable.  But that's NOT the case here.  The
undefined variable here is the symbol `’foobaz' (from
*Messages*) - it really is.

The underlying mistake took place long before Lisp
evaluation of the pasted sexp.



reply via email to

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