Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!edcastle!aiai!jeff From: jeff@aiai.ed.ac.uk (Jeff Dalton) Newsgroups: comp.lang.lisp Subject: Re: Why aren't CL functions 1st class objects? Message-ID: <3437@skye.ed.ac.uk> Date: 21 Sep 90 20:15:07 GMT References: <1990Sep13.202219.21047@oracle.com> Reply-To: jeff@aiai.UUCP (Jeff Dalton) Organization: AIAI, University of Edinburgh, Scotland Lines: 55 In article <1990Sep13.202219.21047@oracle.com> wmesard@oracle.com (Wayne Mesard) writes: >I seem to remember losing an argument a few years ago regarding whether >or not Common Lisp functions were first class objects. The outcome was >that they are not, but I can't remember why. Common Lisp functions are first class. There are reasons why some people think otherwise, such as: * Functions aren't (now it's weren't) a distinct data type. Symbols and certain lists counted as fucntions. (That works just about as well to show that CL doesn't have 1st-class symbols or lists.) * Functions don't have components; there aren't any accessors. (That would show that Scheme didn't have 1st-class fns either, which indeed some people used to claim. Really.) * There are two namespaces with special binding forms (FLET, LABLES) and defining forms (DEFUN) for functions. (That's true, but CL could be used without them. The worst consequence is that calls would all have to use FUNCALL (which we'd have to regard as a special form). That's not a very nice syntax, but I don't see why it would make functions 2nd-class. But to show functions in CL aren't 1st-class you need a definition of "1st-class" that wasn't devised just to attack Common Lisp. And if you look at such lists, they're something like this: - 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. This list is the modern form o"Pop design philosophy" list (1986) taken from Jonathan Laventhol's book "Programming in Pop-11" (written in 1987). Other such lists are similar. However, talk of equality does suggest one way in which Common Lisp might fall a bit short. It turns out that (flet ((f () 't)) (eq #'f #'f)) might return false. Of course, (let ((f #'(lambda () 't))) (eq f f)) always returns true. And that's good enough for me. -- Jeff