Python from Wise Guy's Viewpoint

Matthew Danish mdanish at andrew.cmu.edu
Mon Oct 27 13:40:24 EST 2003


On Mon, Oct 27, 2003 at 07:00:01PM +0100, Andreas Rossberg wrote:
> Pascal Costanza wrote:
> >
> >Can you show me an example of a program that does't make sense anymore 
> >when you strip off the static type information?
> 
> Here is a very trivial example, in SML:
> 
> 	20 * 30
> 
> Multiplication, as well as literals, are overloaded. Depending on 
> whether you type this expression as Int8.int (8-bit integers) or 
> IntInf.int (infinite precision integer) the result is either 600 or an 
> overflow exception.

May I point out that the correct answer is 600, not overflow?

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?

I do believe Haskell does it right, though, with its numeric tower
derived from Lisp.

-- 
; Matthew Danish <mdanish at andrew.cmu.edu>
; OpenPGP public key: C24B6010 on keyring.debian.org
; Signed or encrypted mail welcome.
; "There is no dark side of the moon really; matter of fact, it's all dark."




More information about the Python-list mailing list