Page 1 of 1
(apply case '(...))
Posted: Wed Nov 16, 2005 8:18 am
by Dmi
Code: Select all
(eval '(case 1 (1 "a"))) => "a"
(apply case '(1 (1 "a"))) => nil
What is the difference?
Posted: Wed Nov 16, 2005 1:41 pm
by Lutz
You can use 'apply' only on normal functions evaluating their arguments. In 'case' the parenthesized terms are never evaluated but broken up by 'case' directly to access the innerts. In LISP lingo functions which do not evaluate their arguments are called special functions or special forms because they do not follow the normal evaluation rules.
It is the same as doing:
(apply dotimes '((x 10) (print x))) => fails
;or
(apply setq '(x 10)) => fails
Lutz
ps: I realize this should be mentioned in the documentation of 'apply'
Posted: Wed Nov 16, 2005 2:15 pm
by Dmi
Thanks!