Path: utzoo!attcan!uunet!snorkelwacker!ai-lab!zurich.ai.mit.edu!markf From: markf@zurich.ai.mit.edu (Mark Friedman) Newsgroups: comp.lang.lisp Subject: Re: Why aren't CL functions 1st class objects? Message-ID: Date: 24 Sep 90 18:53:39 GMT References: <1990Sep13.202219.21047@oracle.com> <3437@skye.ed.ac.uk> <3806@goanna.cs.rmit.oz.au> Sender: news@ai.mit.edu Reply-To: markf@zurich.ai.mit.edu Organization: M.I.T. Artificial Intelligence Lab. Lines: 38 In-reply-to: ok@goanna.cs.rmit.oz.au's message of 24 Sep 90 08:32:42 GMT In article <3806@goanna.cs.rmit.oz.au> ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes: In article <3437@skye.ed.ac.uk>, jeff@aiai.ed.ac.uk (Jeff Dalton) writes: > - All objects can be the arguments of procedures. > - All objects can be returned as the results of procedures. > - All objects can be the subject of assignment statements. > - All objects can be tested for equality. However, there is something clearly wrong with this list, because C can satisfy it, and functions aren't first-class in C. In C, a pointer to a function can be passed to a procedure, returned from a procedure, assigned to a variable, or compared for equality to another pointer of the same type. What's C missing? The ability to create (possibly) new functions at run time. From another perspective, *closures* as 1st-class values. In T I can (define (o f g) (lambda (x) (f (g x)) )) and then ((o car cdr) '(1 2 3)) ==> 2 In C, I cannot do this. Seems like an important difference to me. I hate to say it, but C does have closures of a sort. The environment of a C procedure is the union of the bindings of the visible external variables and the bindings of the static internal variables declared in that procedure. What C does not have is general lexical scoping, therefore C closures do not have all the properties that we might like. -Mark -- Mark Friedman MIT Artificial Intelligence Lab 545 Technology Sq. Cambridge, Ma. 02139 markf@zurich.ai.mit.edu