Origin of the term "first-class object"

Terry Reedy tjreedy at udel.edu
Tue Nov 18 01:47:16 EST 2003


"Rainer Deyke" <rainerd at eldwood.com> wrote in message
news:wHcub.227649$Tr4.672235 at attbi_s03...
> I would consider variables to be second-class citizens.

In a sense, 'they' are not even citizens.

In Python, names are syntactic entities, not runtime objects (although
they sometimes get embodied in or represented as strings).  They are
part of the code directing computation but are not the subject of
computation themselves (although strings representing them can be).
(But the CPython interpreter usually  represents local function names
as C integers instead.)  In themselves, names have neither id, type,
nor value, just a current binding to an object that does.

"Variable' is an informal term with multiple meanings even in
mathematics.  In named-memory-block languages like C, a 'variable' is
a name associated with a fixed-address, mutable-content (value) block,
which before 'const', was (to my memory) every number (including
chars), array, and structure/union.

Python, being about objects rather than memory, has no direct
equivalent.  Nor is there a formal definition of 'variable' for
Python.  Python names are used much like C variables, but I think
people sometimes use 'variable' in a way that more refers to objects
than to names.  For instance, in Python 'the value of i' is 'the value
of the ojbect currently associated with i' whereas in C it is 'the
value currently in memory block i'.

> You can change their value,

You can change the value of objects, but only the binding of names.

> delete them,

You can delete objects but only the binding of names.  'Del a' means
unbind 'a' from its currently associated object and if that was the
last remaining binding of that object, make the *object* eligible for
de-existence.

Thus far, you are using 'variable' more to describe objects than
names.

> and get at the object to which they refer,

But here you clearly mean 'variable' = 'name' unless you also mean
'variable' = collection slot or object attribute ('dotted name').

> but you can't do much else with them.

It is hard to do much with an ill-defined abstraction ;-).

Terry J. Reedy







More information about the Python-list mailing list