Path: utzoo!attcan!uunet!know!zaphod.mps.ohio-state.edu!rpi!sci.ccny.cuny.edu!phri!marob!cowan From: cowan@marob.masa.com (John Cowan) Newsgroups: comp.lang.lisp Subject: Re: Why aren't CL functions 1st class objects? Message-ID: <26FE4FEF.48AE@marob.masa.com> Date: 24 Sep 90 18:26:54 GMT References: <1990Sep13.202219.21047@oracle.com> <3437@skye.ed.ac.uk> <3806@goanna.cs.rmit.oz.au> Organization: ESCC, New York City Lines: 32 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. > >[T]here 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. This blurs the rigid distinction C makes between functions and pointers-to- functions. A pointer-to-function is a first-class C object; a function is not. >What's C missing? The ability to create (possibly) new functions at run time. That's not enough. There is no ability in Lisp to create "new" integers at run time; conceptually all the integers already exist. Ditto with all the characters. You cannot have a function in C that accepts a function as an argument or returns a function as a value. Nor can you assign functions. ANSI C relaxes the rules a little so that you can use the same syntax to call a function specified by name or by a pointer-to-function, but the two things are still different, and functions are very much 2nd-class. -- cowan@marob.masa.com (aka ...!hombre!marob!cowan) e'osai ko sarji la lojban