Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!mephisto!pravda!buff From: buff@pravda.gatech.edu (Richard Billington) Newsgroups: comp.lang.lisp Subject: Re: FUNCALL question Message-ID: <19479@mephisto.UUCP> Date: 2 Feb 90 15:29:27 GMT References: <3277@accuvax.nwu.edu> <1990Jan28.175437.19293@hellgate.utah.edu> <1655@skye.ed.ac.uk> <386@forsight.Jpl.Nasa.Gov> <19471@mephisto.UUCP> Sender: news@mephisto.UUCP Reply-To: buff@pravda.UUCP (Richard Billington) Organization: Georgia Institute of Technology Lines: 49 In article pk@tut.fi (Kellom{ki Pertti) writes: >buff> (defun foo3 (x) >buff> (let ((hi #'(lambda () (print "hi there"))) >buff> (bye #'(lambda () (print "hi there")))) >buff> (funcall x))) > >buff> This does work. > >I got an error message from this (using Allegro CL 3.0.3). I suspect >that you had a global function called 'hi', and everything works as >before. Quite right. This was the only thing that really confused me, and it was sloppy investigating on my part. >Previously all I had against CL was it sheer size, but this funcall >stuff has really pissed me off. Using global function bindings seems >to me to violate all the nice rules of lexical scoping. To me it is >simply a dirty hack. Hmmm, I'm not so sure it violates lexical scoping. Now that you've pointed out my error (in the above), it seems to me the behaviour observed in all of my examples is quite consistant with lexical scoping: Within the function definition, the local variable can be referenced with no problem. However, if (as in my example) I try to reference a (dare I say) symbol which is defined within the scope of the function I'm calling, I can't. Why? because the name of the symbol in the calling environment (although identical in print) is different from the name in the internal environment. The only place where one must remember that local variables are not symbols is in the case of (funcall 'x) because if x really was a symbol it would still be hanging around and hence its functional definition would be available. This, however, does not violate lexical scoping. >Moreover, the treatment of functions with all the special forms and >procedures seems to imply that functions in CL are not really first >class citizens, because one has to go thru a *lot* of trouble when >passing them around. Whoever claimed that functions were first class citizens in any other lisp than scheme - I thought that was the single biggest reason for bringing scheme into existance: to have a clean implementation of the lambda calculus, which lisp is NOT (even McCarthy agrees - making functions second class citizens was a mistake). >Pertti Kellom\"aki (TeX format) # These opinions are mine, > Tampere Univ. of TeXnology # ALL MINE ! > Software Systems Lab # (but go ahead and use them, if you like) Richard Billington (buff@pravda.gatech.edu)