Path: utzoo!attcan!uunet!aplcen!samsung!sdd.hp.com!hplabs!otter.hpl.hp.com!otter!sfk From: sfk@otter.hpl.hp.com (Steve Knight) Newsgroups: comp.lang.lisp Subject: Re: Why aren't CL functions 1st class objects? Message-ID: <1350033@otter.hpl.hp.com> Date: 3 Oct 90 11:23:31 GMT References: <1990Sep13.202219.21047@oracle.com> Organization: Hewlett-Packard Laboratories, Bristol, UK. Lines: 44 Jeff Dalton writes (slightly abbreviated by me) on first-classness: > Both the list above and the previous list I posted (from the Pop > Design Philosophy) received the same complaint (this time from you, > last time from Richard O'Keefe), namely that it would be true of > functions in C. So what is wrong? > 1. The people who wrote these lists got it wrong. > 2. The people applying the lists to C have got it wrong. > For example, perhaps the lists aren't really true of > functions in C but only of pointers to functions. > 3. "First-class" doesn't imply all that we sometimes think > it does. Of these suggestions, I am inclined to think that the best answer is (3). It seems unreasonable (to me) to insist that having first-class functions entails lexical binding and/or closure construction. For example, old-style Pop11 used not to have lexical binding but only (shallow) dynamic binding and partial application. However, the designers of Pop11 thought it was reasonable to believe their functions had first-classness. The idea of first-class procedures was a move away from the profound division between data and procedure in programs. It suggests that procedures can participate in all the activities of ordinary data, such as numbers or strings. It seems fair to state that (pointers to) functions in C can partipate in all the operations that numbers, strings, and pointers *share*. As far as I am concerned, this was also true of old-style Lisp lambda-objects, too. Just being first-class is only part of the story. There are two other ideas that are closely associated with being a first-class datatype. In fact, they are so closely connected that some folks argue that they are included in the notion of first-classness. Firstly, there is the idea that objects of different data-types are not confusible i.e. they are tagged with disjoint types. This would exclude lambda-objects that are lists of symbols since they are confusible with lists (they are lists!) and are subject to the operations of lists. Secondly, there is the idea that there is a collection of "natural" operators, or algebra, on the datatype, or carrier. This would exclude C functions, since they lack the typical operations that might be associated with functions, such as composition, partial application, and so on. (Of course, you have to be careful here -- it would be easy to add domain, codomain, inverse, etc ... :-) I think it's the unwritten expectation of these latter two ideas, "disjointness" and "algebra-ness", that causes the surprises. Steve