"Strong typing vs. strong testing"

Lie Ryan lie.1296 at gmail.com
Thu Sep 30 10:55:57 CEST 2010


On 09/30/10 16:09, TheFlyingDutchman wrote:
> 
>>
>> That argument can be made for dynamic language as well. If you write in
>> dynamic language (e.g. python):
>>
>> def maximum(a, b):
>>     return a if a > b else b
>>
>> The dynamic language's version of maximum() function is 100% correct --
>> if you passed an uncomparable object, instead of a number, your call of
>> it is incorrect; you just didn't pass the right sort of data. And that's
>> your problem as a caller.
>>
>> In fact, since Python's integer is infinite precision (only bounded by
>> available memory); in practice, Python's version of maximum() has less
>> chance of producing erroneous result.
> 
> "in C I can have a function maximum(int a, int b) that will always
> work. Never blow up, and never give an invalid answer. "
> 
> Dynamic typed languages like Python fail in this case on "Never blows
> up".

How do you define "Never blows up"?

Personally, I'd consider maximum(8589934592, 1) returning 1 as a blow
up, and of the worst kind since it passes silently.



More information about the Python-list mailing list