From: Stephen E. Bacher
Subject: Re: apply, some, every, eval...
Date: 
Message-ID: <RNETMAIL9103111000278SEB1525@MVS.DRAPER.COM>
 Dunno why my original posting didn't appear in the newsgroup, so
 here goes one more time:
 >
 >>>As for the reason why special forms cannot be FUNCALLed or APPLYe, I reckon
 >>>it has to do with the fact that it is unknown which (if any) args are to
 >>>be evaluated or not.
 >>>
 >>>If SOME or EVERY won't do the job, you could use
 >>> (eval (cons 'or list-of-values))....
 >>
 >>NO WAY.  E.g.:
 >>
 >> (setq list-of-values '(a b c d e))
 >> (apply #'or list-of-values)
 >>
 >> ...pretending for a minute that the above works somehow...
 >>
 >> ==> (apply #'or '(a b c d e))
 >>
 >> But...
 >>
 >> (eval (cons 'or list-of-values))
 >>
 >> ==> (eval (cons 'or '(a b c d e)))
 >> ==> (eval '(or a b c d e))
 >> ==> *ERROR* ; if you're lucky
 >>
 >> What would work is
 >>
 >> (eval (cons 'or (mapcar #'(lambda (x) (list 'quote x)) list-of-values))
 >>

 Now you say:

 >However he missed my second mistake and introduces one of his own
 >in my original note I wrote :

  ...[stuff that called OR and AND special forms instead of macros]...

 >However the criticism that my use of EVAL doesn't work is invalid.
 >EVAL is a function, and thus evaluates the argument. So
 >>
 >>  ==> (eval (cons 'or '(a b c d e)))
 >>  ==> (eval '(or a b c d e))
 >>  ==> *ERROR* ; if you're lucky
 >is wrong.

 Is it?  Did you try the above out on *your* Lisp interpreter?

 Yes, EVAL evaluates its argument, so...

 (eval '(or a b c d e))  ; where list-of-values is '(a b c d e)

 gets an evaluated (QUOTE (OR A B C D E )), which is the list
 (OR A B C D E).  When this is evaluated, execution of the OR macro (or
 special form, depending on your implementation) needs to evaluate the
 form A to see if it's NIL or not.  (The effect would be the same if OR
 were a function:  A would have to get evaluated.)  So if your intent
 was for A,B,C,D,E to be values (as I assumed from your use of the name
 "list-of-values", as well as the general context of the problem), you
 would lose.  That's why you have to quotify each element in the list.

  - SEB