Xref: utzoo comp.lang.misc:6870 comp.object:2729 Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!usc!snorkelwacker.mit.edu!hsdndev!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.lang.misc,comp.object Subject: Re: Dynamic typing -- To Have and Have Not (was Runti Message-ID: <18926:Mar1422:18:5691@kramden.acf.nyu.edu> Date: 14 Mar 91 22:18:56 GMT References: <601@optima.cs.arizona.edu> <19728:Mar1208:45:2291@kramden.acf.nyu.edu> Organization: IR Lines: 68 In article pcg@test.aber.ac.uk (Piercarlo Antonio Grandi) writes: > On 12 Mar 91 08:45:22 GMT, brnstnd@kramden.acf.nyu.edu (Dan Bernstein) said: > Incidentally, I hereby announce my defeat; I have realized that too many > people are using dynamic and static typing to indicate when the type of > *variables* is known. On the contrary. Typing refers to the typing of every single reference in the program, not just ``x'' and ``y''. > brnstnd> a section of program text that refers to > brnstnd> a value. > Normally this is called the scope, No. The scope of a variable is the largest section X of program text such that any part of X may contain a reference to that variable. > In all texts that I know reference > is more or less synonymous with pointer. Yes. The program text ``x + y'', for example, refers to the value computed as the sum of x and y. You can draw an arrow from ``x + y'' to that value if you want. There are languages where a variable may have a reference---a section of program text referring to a value---as a value in and of itself. Sometimes the program text can be made implicit when you have a reference, as in C++. > 2) Don't provide dynamic typing as a language primitive, and make it > possible to implement it more or less grossly on top of the provided > language primitives. So why do you consider this ``gross'' when it's implemented outside the compiler but (presumably) not gross when it's inside the compiler? As long as the language has good syntax, you can hide all the ugliness of (e.g.) polymorphism inside a header file or library. I advocate that this be done for any essentially syntactic feature. > I reckon that Gudeman thinks that Bernstein advocates 1), while > Bernstein really advocates 2); Gudeman himself advocates 3), and I > advocate 4). Actually, I think Gudeman thinks he advocates (4). > an efficient > implementation of dynamic typing as language primitive is not much worse > (thanks to caching and hinting) than one of static typing, For me compile time and typechecking are both important while I'm writing a program. I cannot afford to choose between fast compilations with no typechecking and slow compilations with full typechecking. (Similarly, many programs take a noticeable amount of time for each debugging run. I cannot afford to choose between fast compile time with slow run time and slow compile time with fast run time. My solution for those programs is to optimize by hand, once.) Do you optimize programs while you're testing? Probably not. But when each test run takes a noticeable amount of time, don't you wish that you could make them run faster without wasting so much time on optimization? Similarly, in a dynamically typed language, would you turn on strict typechecking and other optimizations while you're testing? Probably not. But when you make type errors, don't you wish that you could have found them without wasting so much time on optimization? Well, you could. All you had to do was use static typing. ---Dan