Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!tcdcs!swift.cs.tcd.ie!ccvax.ucd.ie!eweb From: eweb@ccvax.ucd.ie Newsgroups: comp.lang.lisp Subject: Re: Problem with (apply #'or )? Message-ID: <47977.27d3f055@ccvax.ucd.ie> Date: 5 Mar 91 19:24:05 GMT References: Organization: University College Dublin Lines: 59 In article seb1525@mvs.draper.com ("Stephen E. Bacher") > In article <47946.27c2d8d3@ccvax.ucd.ie> Eamonn Webster > writes: > >> (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). Thanks for the correction, I realised that I'd made a mistake the moment I had sent the mail, and it was too late. I was thinking I'd got away with it when the discussion moved on to the number of primitives that Common Lisp should have. However he missed my second mistake and introduces one of his own in my original note I wrote : >>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. >> OR and AND are MACROS not SPECIAL FORMS, but the comment still stands. 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. > In general, if you find yourself using EVAL, you're probably taking > a wrong approach somewhere. > As for the use of eval. Well I occasionally work in other languages and a common problem is that I want the user to enter not simply a value, but an expression, (querying a database, for plotting graphs, entering rules in a rule based traffic simulator). In other languages you must read the input, parse it and evaluate it. Referring to program variables is a pain. In Lisp I can simply evaluate the form, being prepared to beep the user if any errors occur. Eamonn Webster eweb@ccvax.ucd.ie Department of Computer Science eweb@ccvax.bitnet University College Dublin Belfield Dublin 4 Ireland Phone +353-1-693244 ext 2484 Fax: +353-1-697262