all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Weird error message "wrong-type-argument symbolp (quote foo)"
@ 2009-06-10 11:45 florian
  2009-06-10 12:12 ` Teemu Likonen
  0 siblings, 1 reply; 4+ messages in thread
From: florian @ 2009-06-10 11:45 UTC (permalink / raw)
  To: help-gnu-emacs

Dear wizards,

I would not have thought that such an error message was possible,
since (quote foo) should be the same as 'foo, hence, a symbol. I have
managed to produce it like this:

(let ((foo 1)
	(bar 2)
	(fubar 3))
    (dolist (var '('foo 'bar 'fubar))
      (message "%S's value is %d"
	       var (symbol-value var))))


The following form, which should produce the same error, however, does
not complain (just as I expected):

(let ((var (quote foo)))
  (symbol-value var))

As expected, it also makes no difference if I write it as

(let ((var 'foo))
  (symbol-value var))

Also, symbolp and symbol-value do not complain if they get sth like
"(quote foo)" as argument. Can anybody point me to what on earth is
going on in the first form? Thanks so much!

Florian


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Weird error message "wrong-type-argument symbolp (quote foo)"
  2009-06-10 11:45 Weird error message "wrong-type-argument symbolp (quote foo)" florian
@ 2009-06-10 12:12 ` Teemu Likonen
  2009-06-10 12:18   ` Teemu Likonen
  0 siblings, 1 reply; 4+ messages in thread
From: Teemu Likonen @ 2009-06-10 12:12 UTC (permalink / raw)
  To: help-gnu-emacs

On 2009-06-10 04:45 (-0700), florian wrote:

> Dear wizards,

I'm not one but...

> I would not have thought that such an error message was possible,
> since (quote foo) should be the same as 'foo, hence, a symbol. I have
> managed to produce it like this:

Unevaluated "(quote foo)" is not a symbol, it's a list. "foo" is a
symbol.

> (let ((foo 1)
> 	(bar 2)
> 	(fubar 3))
>     (dolist (var '('foo 'bar 'fubar))

Here you have double quoting. You quote the list from being evaluated
"'( ... )" and you have also all the three list items quoted.
Effectively all the list items are lists themselves, that is: "(quote
foo) (quote bar) (quote fubar)".

>       (message "%S's value is %d"
> 	       var (symbol-value var))))

So the value of "var" is a list like "(quote foo)" which is not
evaluated anymore. To fix the problem either drop the double-quoting
(see above) or evaluate "var" once more, like "(eval var)".

> The following form, which should produce the same error, however, does
> not complain (just as I expected):
>
> (let ((var (quote foo)))
>   (symbol-value var))

> (let ((var 'foo))
>   (symbol-value var))

These work because there is no double quoting. The value of "var" is
just symbol "foo", not a list "(quote foo)" like in your previous
example.

> Also, symbolp and symbol-value do not complain if they get sth like
> "(quote foo)" as argument. Can anybody point me to what on earth is
> going on in the first form? Thanks so much!

Actually only in your first, broken example "symbolp" and "symbol-value"
get a list like "(quote foo)" as argument and thus they complain. In
your latter examples they get symbol "foo" as argument. The reason is
the double quoting.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Weird error message "wrong-type-argument symbolp (quote foo)"
  2009-06-10 12:12 ` Teemu Likonen
@ 2009-06-10 12:18   ` Teemu Likonen
  2009-06-12 19:46     ` florian
  0 siblings, 1 reply; 4+ messages in thread
From: Teemu Likonen @ 2009-06-10 12:18 UTC (permalink / raw)
  To: help-gnu-emacs

On 2009-06-10 12:12 (UTC), Teemu Likonen wrote:

> Actually only in your first, broken example "symbolp" and "symbol-value"
> get a list like "(quote foo)" as argument and thus they complain. In
> your latter examples they get symbol "foo" as argument. The reason is
> the double quoting.

I meant "the reason [for this difference] is the [previously mentioned]
double quoting".


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Weird error message "wrong-type-argument symbolp (quote foo)"
  2009-06-10 12:18   ` Teemu Likonen
@ 2009-06-12 19:46     ` florian
  0 siblings, 0 replies; 4+ messages in thread
From: florian @ 2009-06-12 19:46 UTC (permalink / raw)
  To: help-gnu-emacs


Dear Teemu,

> > The reason is the double quoting.

thanks so much. Such a stupid error ... (I mean, I should have been
plainly VISIBLE to me, especially given the absolutely informative
error message, but sometimes ...)

Thanks very much for pointing me there, anyway!

Best regards,
Florian


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-06-12 19:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-10 11:45 Weird error message "wrong-type-argument symbolp (quote foo)" florian
2009-06-10 12:12 ` Teemu Likonen
2009-06-10 12:18   ` Teemu Likonen
2009-06-12 19:46     ` florian

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.