2

I've never quoted nil before, as I can't see any sense in doing that, but I just played around with some code and it seems that in most cases it is possible to quote nil without any effect. However when I use condition-case with a quoted nil as the first argument, I get an error (wrong-type-argument symbolp (quote nil)).

(condition-case 'nil
    (/ 2 0)
  (error "foo"))

Why does quoting nil cause problems when using it this way ?

1
  • Hint: nil is not really relevant, e.g., (condition-case 'some-other-symbol ...) also doesn't work.
    – npostavs
    Nov 21 '16 at 20:46
2

Whenever the variable in question is evaluated, 'nil and nil are the same.

E.g., all functions (but not necessarily macros and special forms!) get their arguments evaluated.

If it is not evaluated, like the first argument of the special form condition-case, you cannot quote it because then you are passing a list (quote nil) instead of the symbol nil.

4
  • Thanks for the answer, but I had to read a more detailed answer to understand this emacs.stackexchange.com/a/722/11377.
    – bertfred
    Nov 21 '16 at 21:14
  • @bertfred: yes, your question was marked a dupe for a reason! :-)
    – sds
    Nov 21 '16 at 21:21
  • Without your answer I wouldn't have realized, that the macro was the reason ;)
    – bertfred
    Nov 21 '16 at 21:26
  • Technically condition-case is not a macro, but a special-form.
    – politza
    Nov 21 '16 at 21:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.