Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!snorkelwacker.mit.edu!apple!bionet!agate!ucbvax!mvs.draper.com!seb1525 From: seb1525@mvs.draper.com ("Stephen E. Bacher") Newsgroups: comp.lang.lisp Subject: Re: Problem with (apply #'or )? Message-ID: Date: 22 Feb 91 13:34:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 56 In article <47946.27c2d8d3@ccvax.ucd.ie> Eamonn Webster writes: >I agree that it seems odd that special forms can't be APPLYed or FUNCALLed, >however in your particular example, what you are missing are the functions >EVERY, SOME, NOTANY and NOTEVERY, (CLtL, 1st Ed, page 250). > > (apply #'or list-of-values) == (some list-of-values) > (apply #'and list-of-values) == (every list-of-values) Wrong - should be: (apply #'or list-of-values) == (some #'identity list-of-values) (apply #'and list-of-values) == (every #'identity list-of-values) If you don't have the IDENTITY function, use #'(lambda (x) x). Or (n.p.i.), for the "and" case: (not (member nil list-of-values)) >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)) The point is, however, that it is usually a bad idea to use EVAL. At least in this case it won't fail, since there are no variable scoping issues afoul of which to run. But you take an efficiency hit. In general, if you find yourself using EVAL, you're probably taking a wrong approach somewhere. - SEB