What is a function?
To understand why this happens, we need to know what is a function. When evaluating the lisp form (myfunc arg1 arg2 ...)
, emacs first checks what myfunc
is. If it is a function, emacs evaluates all lisp forms arg1
, arg2
, etc. then calls the function myfunc
with the resulting lisp objects as arguments.
As was noted, and
is not a function, it is a special form, thus it can evaluate its arguments as needed. As I gave in a comment earlier, the form (and nil (drop 'bomb))
is safe because (drop 'bomb)
is never evaluated.
On the other hand, (apply #'and (list nil (drop 'bomb)))
is not safe, because apply
is a function, so emacs first evaluates #'and
(the result is a symbol), then evaluates (list nil (drop 'bomb))
, which is again a function call, so you guess what happens next : nil
is evaluated, then (drop 'bomb)
is evaluated.
Why does apply
complain ?
Trying to use apply
on a special form (or a macro) doesn't make sense, because the special form can't possibly have its special behaviour, so it throws an error.
and
is a special form rather than a function. – Dan Sep 04 '15 at 19:19(cl-every 'identity lst)
or(-all? 'identity lst)
. – wasamasa Sep 04 '15 at 19:22