Origin of the term "first-class object"

John Roth newsgroups at jhrothjr.com
Mon Nov 17 17:11:55 EST 2003


"Hung Jung Lu" <hungjunglu at yahoo.com> wrote in message
news:8ef9bea6.0311171335.356a7af6 at posting.google.com...
> Hi,
>
> Does anybody know where this term comes from?
>
> "First-class object" means "something passable as an argument in a
> function call", but I fail to see the connection with "object class"
> or with "first-class airplane ticket". I just find the name a bit
> strange. Also, if there are first-class objects, what would the
> second-class objects or economy/tourist class objects be? :)
>
> Just wondering,

I'm not sure who started to use it, but to me it means that
there are no restrictions on the object's use. It's the same as
any other object. I'm also not sure what being able to pass
it in a function call has to do with it; I'm used to being
able to use them in a lot of other ways.

For example, in Python both classes and functions are
objects (there are no second class citizens in Python...)
This means that I can rebind a class object into another
module at run time, and access it under its new name.
I can thow functions around with wild abandon, and even
add attributes to them for some meta-data scheme, for
example.

In Java, neither classes nor methods are first class
objects, even though you can get a "class" object
if you ask politely, it's simply a special construct
for the reflection mechanism.

In C++, neither is an object, first class or not.

John Roth


>
> Hung Jung






More information about the Python-list mailing list