Python from Wise Guy's Viewpoint
Pascal Costanza
costanza at web.de
Mon Oct 27 20:46:54 EST 2003
Marcin 'Qrczak' Kowalczyk wrote:
> On Mon, 27 Oct 2003 13:40:24 -0500, Matthew Danish wrote:
>
>
>>Something that annoys me about many statically-typed languages is the
>>insistence that arithmetic operations should return the same type as the
>>operands. 2 / 4 is 1/2, not 0. Arithmetically, 1 * 1.0 is
>>well-defined, so why can I not write this in an SML program?
>
>
> Confusing integer division with rational division is not a consequence
> of static typing, except that with static typing it's not as dangerous as
> with dynamic typing (because a function declared as taking floating point
> arguments and performing / on them will do the same even if you pass
> integers to it, which in most languages will be automatically converted).
Sorry, I don't get this. Why should it be more dangerous with dynamic
typing? Common Lisp definitely gets this right, and most probably some
other dynamically typed languages.
> Mixed-type arithmetic is a different story. I'm talking only about 1/2
> being equal to 0 in some languages - this doesn't coincide with static
> typing.
Yes, dynamic vs static typing seems to be irrelevant here. (Although I
wonder why you should need to distinguish between / and div...)
Pascal
More information about the Python-list
mailing list