Origin of the term "first-class object"

Ben Finney bignose-hates-spam at and-benfinney-does-too.id.au
Tue Nov 18 08:09:55 CET 2003


On Tue, 18 Nov 2003 03:01:35 GMT, Rainer Deyke wrote:
> John Roth wrote:
>> I can't think of anything I can't do with a name that I might want
>> to.
>
> One would be passing a name as an argument
> to a function.

To accomplish what?  What would you be doing with the name that you
can't do just as easily by passing the object (by reference, as always
happens in Python)?

> Given the immutability of certain Python objects, it is
> often necessary to write statements in the form of
> "x = f(x)".

I don't understand the logic here.  What is it that necessitates
"x = f(x)", and why is that undesirable?

> This is a violation of the Once And Only Once principles, since it
> mentions the same variable twice.

I've never heard of that principle.  Surely one of the main advantages
of naming an object is to use that name in multiple places to refer to
the object?

I can't think how you'd write any non-trivial program to work with
objects that *doesn't* "mention the same [object] twice", nor what you'd
gain by doing so.

Perhaps you're referring to a principle sometimes called the Single
Point Of Truth (SPOT), which requires that, ideally, there be one and
only one canonical place where each datum resides.  This is quite
separate to the names given to objects within the program -- having a
SPOT for each datum is *enabled* by using the same name multiple times
within the program.

> Language design is a series of trade-offs, and the simplicity and
> clarity of Python may very well make up for its limitations.  However,
> that doesn't mean that the limitations are not real.

I'll have to ask you to explain those limitations, I can't understand
them as you've expressed them here.

-- 
 \        "Kissing a smoker is like licking an ashtray."  -- Anonymous |
  `\                                                                   |
_o__)                                                                  |
Ben Finney <http://bignose.squidly.org/>




More information about the Python-list mailing list