Python from Wise Guy's Viewpoint

Pascal Costanza costanza at web.de
Fri Oct 24 18:05:20 EDT 2003


Brian McNamara! wrote:
> Pascal Costanza <costanza at web.de> once said:
> 
>>Marshall Spight wrote:
>>
>>>I agree these programs exist.
>>>
>>>It would be really interesting to see a small but useful example
>>>of a program that will not pass a statically typed language.
>>>It seems to me that how easy it is to generate such programs
>>>will be an interesting metric.
>>>
>>>Anyone? (Sorry, I'm a static typing guy, so my brain is
>>>warped away from such programs. :-)
>>
>>Have you ever used a program that has required you to enter a number?
>>
>>The check whether you have really typed a number is a dynamic check, right?
> 
> 
> Yes, but this doesn't imply we can't write a statically-typed program to
> handle the situation...
> 
> I can imagine Haskell code like
> 
>    y = do x <- myread "34"
>           return x * 2
>    z = do x <- myread "foo"
>           return x * 2
> 
> where
> 
>    myread :: String -> Maybe a
>    y, z :: Maybe Int
> 
> and "y" ends up with the value "Just 68" whereas "z" is "Nothing".

The code you have given above doesn't give the user any feedback, right? 
Do you really think that this is useful?


Pascal

-- 
Pascal Costanza               University of Bonn
mailto:costanza at web.de        Institute of Computer Science III
http://www.pascalcostanza.de  Römerstr. 164, D-53117 Bonn (Germany)





More information about the Python-list mailing list