From ... Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!fr.usenet-edu.net!usenet-edu.net!deine.net!hamster.europeonline.net!newsfeed.europeonline.net!nslave.kpnqwest.net!nloc.kpnqwest.net!nmaster.kpnqwest.net!nreader2.kpnqwest.net.POSTED!not-for-mail Newsgroups: comp.lang.lisp Subject: Re: Why is Scheme not a Lisp? References: <87k7sglz66.fsf@becket.becket.net> Mail-Copies-To: never From: Erik Naggum Message-ID: <3225069211869395@naggum.net> Organization: Naggum Software, Oslo, Norway Lines: 67 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 14 Mar 2002 04:33:21 GMT X-Complaints-To: newsmaster@KPNQwest.no X-Trace: nreader2.kpnqwest.net 1016080401 193.71.199.50 (Thu, 14 Mar 2002 05:33:21 MET) NNTP-Posting-Date: Thu, 14 Mar 2002 05:33:21 MET Xref: archiver1.google.com comp.lang.lisp:28866 * Thomas Bushnell, BSG | (define (sum term a next b) | (if (> a b) | 0 | (+ (term a) | (sum term (next a) next b)))) | | People have barely begun the course when they get to this. In CL, | you'd do the same thing if you wanted, by passing in functions and | using APPLY to call them. apply? Scheme and Common Lisp both need apply for exactly the same reason. Scheme and Common Lisp differ in the use of _funcall_. I have such pity on you poor Scheme victims that I wrote the following little macro just to prove that Common Lisp is able to accomodate your needs painlessly: at the very least it removes the funcall allergen. (defmacro with-functions (functions &body body) `(macrolet ,(mapcar (lambda (function) `(,function (&rest args) `(funcall ,',function ,@args))) functions) (locally (declare (function ,@functions)) ,@body))) | So in one sense, it's trivial to translate. However, it would totally | defeat the pedagogic purpose to have to talk about APPLY at such an early | stage. But would you talk about apply in a Scheme text unless you had a list of variables? Something tells me you are reaching, not just mistaken. Anyway, you can now write (defun sum (term a next b) (with-functions (term next) (if (> a b) 0 (+ (term a) (sum term (next a) next b))))) instead of the supposedly horribly inelegant (defun sum (term a next b) (if (> a b) 0 (+ (funcall term a) (sum term (funcall next a) next b))))) I frankly do not see how this minor problem turns into this major deal for Schemers. Common Lispers change their language if something bothers them too much. In an educational setting, it is not unusual for the teacher/master to set up a more pedagogical environment than programmers usually use. If one uses or teaches the use of functions in variables a lot, I think it even makes sense to adopt a style like the above, since funcall may indeed make the code less readable. with-functions also provides the lexically evident clues that these names are special. The programmer does not have to check every function call to be certain that it has a different lexical than global meaning, as one must do in Scheme. There is no accidental "overwriting" global function definitions: You may call a variable "list" as long as you do not hand it to with-functions. /// -- In a fight against something, the fight has value, victory has none. In a fight for something, the fight is a loss, victory merely relief.