Article View: comp.lang.misc
Article #2983Re: Dynamic typing -- To Have and Have Not
From: David Gudeman
Date: Thu, 14 Mar 1991 10:41
Date: Thu, 14 Mar 1991 10:41
36 lines
2220 bytes
2220 bytes
In article <1991Mar13.195039.22587@mathrt0.math.chalmers.se> Lennart Augustsson writes: ]In article <614@optima.cs.arizona.edu> gudeman@cs.arizona.edu (David Gudeman) writes: ]I don't agree. I think that a lot of people who prefer dynamically ]typed languages are ignorant of the alternatives. I doubt there are many people who are only experienced with dynamically typed languages. If you are refering to type inference as the alternative, you may be right -- people who prefer dynamically typed languages may tend to be unaware of it (like everyone else), but I doubt they would like it, ignoring efficiency issues and sticking strictly to expressiveness and program reliability. When worried about efficiency, everyone prefers statically typed languages, I never meant to claim otherwise. 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). But at least it solves the problems of errors in declarations and having to make pervasive changes to the code when you change declarations. ] 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? -- David Gudeman gudeman@cs.arizona.edu noao!arizona!gudeman
Technical Details
Message-ID:
<628@optima.cs.arizona.edu>Path:
arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!caen!news.cs.indiana.edu!arizona.edu!arizona!gudemanShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!caen!news.cs.indiana.edu!arizona.edu!arizona!gudeman From: gudeman@cs.arizona.edu (David Gudeman) Newsgroups: comp.lang.misc Subject: Re: Dynamic typing -- To Have and Have Not Message-ID: <628@optima.cs.arizona.edu> Date: 14 Mar 91 10:41:45 GMT Sender: news@cs.arizona.edu Lines: 36