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 ?

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

1 Answers1

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.

sds
  • 5,928
  • 20
  • 39