Xref: utzoo comp.object:3020 comp.lang.misc:7260 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!hsdndev!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.object,comp.lang.misc Subject: Re: Type Systems and Dynamic Binding Message-ID: <11479:Apr319:53:2191@kramden.acf.nyu.edu> Date: 3 Apr 91 19:53:21 GMT References: <3776@ssc-bee.ssc-vax.UUCP> Organization: IR Lines: 75 In article <3776@ssc-bee.ssc-vax.UUCP> dmg@ssc-vax.uucp (David M Geary) writes: >In article <7689:Mar2623:28:5091@kramden.acf.nyu.edu>> (Dan Bernstein) writes: >>>In article <48805@nigel.ee.udel.edu> new@ee.udel.edu (Darren New) writes: >>>Hmm... How about a window with a hetrogeneous collection of buttons, sliders, >>>text displays, etc, all of which respond to "redraw" and "is the mouse >>>over you"? >>struct {any object; void (*redraw)(); int (*ismouseover)();} *whatsinwindow(); [ ... ] >NO. This is *not* an example of dynamic typing implemented on top of C. What a load of... uh, what I mean is that this is a perfect example of the fact that dynamic typing is just a programming technique. (``A state of mind'' is perhaps too fluffy for such a serious discussion as this.) With appropriate macros, I can use the above structure in the same way as someone using a dynamically typed language. In fact, with a reasonable preprocessor like AT&T's C++, I can declare the structure in the same way. I can get all the same type-checking (at run-time, too!). You can shout all you want about it not *really* being dynamic typing. But it obviously is. Why does it so offend you that dynamic typing can be implemented so effectively outside the compiler? > A void* is not a "polymorphic type", and C++ provides much more than > "merely syntactic sugar". Uh-huh, whatever you say, boss. > > On the occasions when I want dynamically typed variables, I > >can use them without trouble in C. > No you cannot; C has no support whatsover for "dynamically typed variables." It has a macro facility that is adequate to let me use a variable, x, that can take on any value I can express in the language, and that forces me to use x as the type it is currently holding. What else do you want out of types, other than the syntax and the checking? > One cannot "implement > dynamic typing on top of C", without writing some kind of preprocessor, In case you haven't noticed, C has a preprocessor. It's not great, but it works. But even if it didn't, I would happily use m4. As I've said before, you cannot change the fundamental characteristics of a language by adding a library---or a preprocessor. > Here, one is adding arbitrary elements to a collection. There is > *no restriction whatsoever* as to the type of things that can be > added to the collection. Note that this differs from the C++ example, > where all elements added to the list *must* be linkables (or > descendents of class linkable). Nobody has come up with any examples of why anyone would want to use such a list---i.e., a list which does not have a definite type, and to which you cannot meaningfully apply any particular operations. Do you have a brilliant example that everyone else has missed? > Lastly, note that neither of the two examples given above may be > implemented in C, without the programmer *at one time or another* > explicitly identifying the types of all objects being operated upon. C++ is a counterexample. > Here, BTW, are some good references. I would suggest that Dan read > some of these before providing any more erroneous information in the > tradition of his previous postings: Why, thank you, ma'am. Here, BTW, is an excellent reference. I strongly suggest that you read it---and work at least 10% of the exercises---before you post anything, again, anywhere, ever. Art of Computer Programming, Donald E. Knuth. 3 volumes. ---Dan