PEP 276 (was Re: Status of PEP's?)

James_Althoff at i2.com James_Althoff at i2.com
Mon Mar 4 15:26:48 EST 2002


Carel,

Thanks for the explanation, below.  Very interesting.

Yes, I agree with your basic analysis that producing an iterator for an
integer makes a lot more sense if one accepts integers as first-class
objects.  The fact that Python treats integers as well as everything else
as first-class objects is one of the big reasons why I like Python so much.

Jim

===========================================================================

Carel Fellinger wrote >>>>>>>>>>>>>>>>>

Jim, I think I finally solved the riddle.

>From your first post on this subject I had this voice in the back of
my head telling me: think objects.  The post I'm responding to now
reinforced that voice, so I finally gave in:)

In 2.2 we happily see the type/class split healed.  And one of the
consequences of that is that we now *see* that integers have methods,
we can even call them:

    >>> (1).__add__(2)
    3

To you, comming from smalltalk, that's just how it's supposed to be,
but to me it looks a little awkward.  Probably because to me integers
are a mathematical abstraction, and I don't see how it could know how
to add.  Addition is something that's not inherent to integers but a
layer that's put on top of integers.  I guess this just goes to show
my ignorance on mathematical issues:(

And now you're stretching this object oriented view of integers even
further.  You ask an integer to iterate or, if you like, to count.


The funny thing however is that I don't have this reservation with
strings:) Strings to me have always been a programmers construct,
there are no character strings in the real world, but they sure come
in handy in a program.  When I made the switch to OO I saw that it was
practical and sound to put the actions and the data together.  So the
same for strings.  I ask a string whether it has uppercase chars, I
ask it to split itself, to count itself (len).  I'm even prepared to
ask it to translate itself. No problem.  I just never made that step
for numbers.

And I'm not alone in that.  I remember from the 80's that there were
heated discussions whether to go `all the way' and define integers to
be objects or stop at the level of some primitive types when defining
the object hierarchy.  There were implementation issues but also
filosofical and usability considerations.  Some language designers
choose to hide the object nature of integers from the programmers and
provided a bunch of syntactic sugar solely to make number manipulation
look more like ordinary math.

To conclude, you propose to go `all the way' with treating integers as
objects, and some of use haven't been exposed to such a thing long
enough to either be blind for its pecularity or to finally appreciate
its soundness.

I think given enough time and exposure I can get to appreciate it,
I don't know for the public in general.  And though we hardly hear
off it these days, Guido is aiming at `programming for everybody'.

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<





More information about the Python-list mailing list