Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!spool.mu.edu!uwm.edu!uwvax!daffy!saavik.cs.wisc.edu!quale From: quale@saavik.cs.wisc.edu (Douglas E. Quale) Newsgroups: comp.lang.misc Subject: Re: Run-time Type Errors in Smalltalk Message-ID: <1991May16.134106.24421@daffy.cs.wisc.edu> Date: 16 May 91 13:41:06 GMT References: <1991May13.082152.29294@tkou02.enet.dec.com> <1991May15.141839.20603@daffy.cs.wisc.edu> <1991May16.011804.21042@tkou02.enet.dec.com> Sender: news@daffy.cs.wisc.edu (The News) Organization: University of Wisconsin -- Madison Lines: 49 One of the difficulties that proponents of static typing have in convincing folks who enjoy the benefits of dynamic typing to switch is that the type systems of the most popular statically typed languages are very primitive and inflexible. Compare C/Pascal/Ada to Common Lisp, for instance. The claimed benefit of extra safety simply doesn't exist with most C compilers. ANSI C is a big improvement in this regard but backward compatibility is a real hindrance to type safety. Another issue is that _very_ often I don't care what type a value is. It may be the result of a library call and then simply be fed into another call. For instance, I recently spent more than a couple of minutes figuring out what was wrong with a C program with this fragment: { ... double f, foo; int i; ... f = modf(foo, &i); ... switch (i) { ... } } This is a type error that the $%#!!% compiler didn't catch (Yes, I did include math.h). All that was done with i was to use it in a switch statement, and no runtime errors occured, it just gave the wrong answers (i was always 0). It wasn't immediately obvious that the modf call was to blame, but once I got that far checking the man page I found that modf is double modf(double, *double). Changing i to double fixed the problem. (This error occured because a certain useless pocket reference to the C libraries said i should be int. I'm glad I didn't pay anything for it, or I'd be even more pissed.) Ada would have caught this type error, but among other things I don't have an Ada compiler. (Even if I did, I'd have to learn Ada to be able to get much use from it. :) The point is, I don't care what numeric type i is. In a dynamically typed language this type error would not occur. In dynamically typed languages a lot of things that can be type errors in static languages simply *cannot* cause errors. I think much of the belief in the extra safety of statically typed languages is based on experience with C, where uncaught type errors are a common and serious problem. C is a terrible example that gives all of the disadvantages of static typing with very little safety in return. -- Doug Quale quale@saavik.cs.wisc.edu