Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think.com!paperboy!hsdndev!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.lang.misc Subject: What ``first-class'' means in comp.lang.misc Message-ID: <25449:Jan823:00:2991@kramden.acf.nyu.edu> Date: 8 Jan 91 23:00:29 GMT Sender: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Organization: IR Lines: 68 There is certainly some confusion here over what ``first-class'' means. Here's a summary of what several people have said about first-class objects in recent discussions here. Three people---Dave Gudeman, Norman Graham, and I---seem to agree on a single definition of first-class. Among other things, the definition implies that function pointers in C and structures in ANSI C are first-class, and that structures in pre-ANSI C are not first-class. All the other definitions disagree with each other on some particular. Must it be possible to return first-class objects from functions? Not if you believe Dybvig (as quoted by Dickey). Must it be possible to pass them as arguments? Not if you believe Clinger (as quoted by Ozan). Are C's integers first-class? Only if you believe Lennart. Without further ado, here's the complete summary. I think the only statement we can all agree with is Lennart's claim that ``first-class'' has several definitions. In <304@coatimundi.cs.arizona.edu> Dave Gudeman defines ``first-class'' as follows: ``The type of the object in question can be passed as an argument to procedures and returned from procedures as a result. In procedural languages like C, it also means that you can assign the values to variables.'' He says that C's function pointers are first-class. (Just in case somebody's been asleep through this discussion: This is the same definition that I'm familiar with, and I agree with the conclusion.) In <1990Dec19.222059.6878@mathrt0.math.chalmers.se> Lennart Augustsson made a claim that, if read literally, implies that first-class functions must be composable. In <1990Dec29.101233.1894@mathrt0.math.chalmers.se> Lennart says that ``first-class'' has several definitions. One of them, he says, is this: ``For a type to be first class it should be possible to do the same things with its objects as with objects of other types, such as integers.'' He says that this includes not only argument passing but ``be expressible without giving it a name.'' He says that (ANSI) C's structures are not first-class, but that gcc's structures are, because gcc lets you write unnamed struct values. In <1991Jan7.185658.20240@basho.uucp> John Lacey says that ``first-class'' implies having ``the right to be anonymous.'' In <20021@yunexus.YorkU.CA> Ozan Yigit quotes William Clinger. Clinger doesn't actually claim to define ``first-class'' in the quoted material, but Ozan appears to believe that the properties listed form a definition: having the right to remain anonymous, having an identity independent of any names by which the object may be known, being storable in variables and in data structures without losing their identity, being returnable from a procedure, and never dying. In <1991Jan7.154111.5166@d.cs.okstate.edu>, Norman Graham says that C has first-class function pointers. He distinguishes between first-class functions and first-class function pointers. Finally, to complete this comedy of definitions, Ken Dickey claims in <442@data.UUCP> that first-class objects do not have to be named, and in <443@data.UUCP> quotes Guy Steele. According to Steele, ``full-fledged'' objects may be passed as arguments, returned as values, made part of composite data structures, and notated as independent, unnamed entities. He also quotes Kent Dybvig: ``Procedures are first-class data objects similar to strings or numbers; identifiers are bound to procedures in the same way they are bound to other objects.'' If we take this as a definition, then ``first-class'' means only the identity properties listed by Clinger, and does not include argument passing. ---Dan