Python from Wise Guy's Viewpoint
Pascal Costanza
costanza at web.de
Mon Oct 27 14:54:06 EST 2003
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.
>
> So the program does not make sense without type information, because it
> does not have an unambiguous (i.e. no) semantics.
>
> I'm ready to admit that it may be a dubious example of a typing feature.
> But it is simple, and clearly sufficient to disprove your repeated claim
> that static types don't add expressiveness to a language. If you did not
> have them for the example above, you needed some other feature to
> express the disambiguation.
Sorry, do you really want to say that I can't make my program throw an
exception when some variables are not inside a specified range?
(assert (typep (* 20 30) '(integer 0 255)))
Pascal
More information about the Python-list
mailing list