Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!asuvax!noao!arizona!gudeman From: gudeman@cs.arizona.edu (David Gudeman) Newsgroups: comp.lang.misc Subject: Re: Dynamic typing (part 3) Message-ID: <1707@optima.cs.arizona.edu> Date: 10 Apr 91 17:13:09 GMT Sender: news@cs.arizona.edu Lines: 31 In article <1991Apr9.110217.10963@mathrt0.math.chalmers.se> Lennart Augustsson writes: ]In article <1593@optima.cs.arizona.edu> gudeman@cs.arizona.edu (David Gudeman) writes: ]> If f is a function and s is a sequence, then map(f,s) is the ]> sequence t such that for all i . t[i] = f(s[i]). ]> ]>In a Icon (a dynamically typed language) you could define... ]> ]>Try to write this function in a statically typed language so that it ]>has all the generality of the math and Icon versions. ]Sorry, I can't forget it. I'll just have to make another plug for ]polymorhic type deduction. Here's a version of map in Haskell (ML ]would be very similar): ] ] map f [] = [] ] map f (x:xs) = f x : map f xs I'm getting really tired of pointing this out: the program above does not have the full generality of the mathematical or the dynamically typed version. This is a point I've made several times on several Haskell and ML programs, and I wish people would get the idea so I could stop repeating myself. The statically typed program only works on structures in which all elements have the same type -- and only when the compiler can infer that type. Type inference has some nice features, but it does _not_ give you the expressive power of dynamic typing. -- David Gudeman gudeman@cs.arizona.edu noao!arizona!gudeman