Python from Wise Guy's Viewpoint

Pascal Costanza costanza at web.de
Mon Oct 27 20:54:11 EST 2003


Matthias Blume wrote:

> Pascal Costanza <costanza at web.de> writes:
> 
> 
>>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?
> 
> 
> No.  Where did you get that from.
> 
> His point was that without the type information you don't know whether
> the above "program" should be transliterated into this:
> 
> 
>>(assert (typep (* 20 30) '(integer 0 255)))
> 
> 
> or simply this:
> 
>    (* 20 30)

Well, what's the obvious meaning?

Meta comment: I think we are already side-stepping too much here. I 
don't think this is a useful example to illustrate serious advantages of 
either static or dynamic typing. In all languages, you could simply 
define a default meaning for the version that doesn't have explicit type 
annotations, and then force the programmer to use explicit annotations 
for the other ones. (Andreas already said it is a dubious example.)

Can you give a better example of a program that would render meaningless 
without type annotations?

Pascal





More information about the Python-list mailing list