Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!usc!rpi!uupsi!sunic!chalmers.se!mathrt0.math.chalmers.se!augustss From: augustss@cs.chalmers.se (Lennart Augustsson) Newsgroups: comp.lang.misc Subject: Re: Dynamic typing -- To Have and Have Not Message-ID: <1991Mar14.203404.1444@mathrt0.math.chalmers.se> Date: 14 Mar 91 20:34:04 GMT References: <628@optima.cs.arizona.edu> Sender: news@mathrt0.math.chalmers.se (Evald Nyhetsson) Organization: Dep of Computer Sciences, Chalmers, Gothenburg Lines: 28 In article <628@optima.cs.arizona.edu> gudeman@cs.arizona.edu (David Gudeman) writes: >Statically typed languages without declarations are a step in the >right direction, but not far enough for my taste. You are still too >restricted in the sorts of expressions you are allowed to write (not >to mention that for non-toy languages, compilation is slow as a >beejeeber). I don't know what implementations you have tried, I don't think ML style type inference is particularely slow (except on pathological examples). >] tree_insert Null x = Node x Null Null >] tree_insert (Node y l r) x | x < y = Node (tree_insert l x) r >] tree_insert (Node y l r) x = Node l (tree_insert r x) >]The compiler infers the type (i.e. you don't have to write it!) >] tree_insert :: (Ord a) => Tree a -> a -> Tree a >]which means that tree_insert will work on any type of data that is a >]member of class Ord (i.e. has < defined). > >Can you use this function to insert different types in the same tree? >If so, how is it different from dynamic typing? No, one particular tree can only contain values of one type. I know you find this too restrictive, I was just trying to point out that compile time type checking does not imply that you have to declare the type of the functions you define. -- Lennart Augustsson [This signature is intentionally left blank.]