Python from Wise Guy's Viewpoint

Brian McNamara! gt5163b at prism.gatech.edu
Fri Oct 24 17:40:18 EDT 2003


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".

-- 
 Brian M. McNamara   lorgon at acm.org  :  I am a parsing fool!
   ** Reduce - Reuse - Recycle **    :  (Where's my medication? ;) )




More information about the Python-list mailing list