(apply case '(...))

Started by Dmi, November 16, 2005, 12:18:03 AM

Previous topic - Next topic

Dmi

(eval '(case 1 (1 "a"))) => "a"
(apply case '(1 (1 "a"))) => nil

What is the difference?
WBR, Dmi

Lutz

#1
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'

Dmi

#2
Thanks!
WBR, Dmi