[Types-sig] Sample declarations
Paul Prescod
paulp@ActiveState.com
Wed, 14 Mar 2001 06:40:58 -0800
Guido van Rossum wrote:
>
> ...
>
> No, the situation is approximately as murly as for sequences, mappings
> or files.
Okay, I'll define Number as the union of complex, integer and float. If
anyone wants it to be more general then that they can work out the
"general principles" of numerics.
>..
>
> It's an implementation quirk that this works -- it really shouldn't!
> Note that even 5.1 as the buffer size works -- and *that* *really*
> shouldn't be allowed.
Okay, I'll make the various types non-interchangable for now and then
loosen the rules when we have a proper type hierarchy.
> What you want is a cast. We have cast functions named after the
> concrete types, e.g. int(), float(), long(), etc.
I would like to have a single cast operator that takes a type object. We
could ask both the object and the type if they knew how to cast back and
forth. So if you pass an int or complex where code needs a float, the
object would be automatically casted. I'm not going to design a more
generalized casting model as part of this effort but I have a sense that
if we had such a thing, it would be much easier to ensure consistency of
casting everywhere. C extensions would behave the same as operators
which would behave the same as Python code...
> Can I make a comment on these comments? You seem to be using comments
> only when there's something not 100% kosher in your code. An implied
> "XXX". :-) I'd appreciate to see more comments that actually explain
> what you are doing and why, rather than what you are *not* (yet)
> doing! (Most of JPython was once written using this convention --
> while it was clean code, it was very hard to read for the second
> developer...)
Okay.
--
Python:
Programming the way
Guido
indented it.
- (originated with Skip Montanaro?)