Xref: utzoo comp.object:3222 comp.lang.misc:7494 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!batcomputer!cornell!uw-beaver!fluke!ssc-vax!dmg From: dmg@ssc-vax.uucp (David M Geary) Newsgroups: comp.object,comp.lang.misc Subject: Re: Type Systems and Dynamic Binding Message-ID: <3864@ssc-bee.ssc-vax.UUCP> Date: 17 Apr 91 19:52:42 GMT Sender: news@ssc-vax.UUCP Organization: Boeing Aerospace & Electronics Lines: 73 Originator: dmg@ssc-vax ] Dan Bernstein ]] David Geary ]]] Darren New ]] Dan Bernstein claims to be able to implement dynamic typing on top of C: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ] David, there is a big difference between claiming that a *particular* ] example of dynamic typing can be implemented (directly) in C, and ] claiming that *all* examples of dynamic typing can be implemented ] (directly) in C. As you will realize if you reread your article, I have ] claimed the former, for several particular examples. I have not claimed ] the latter ... ] For each EXAMPLE of dynamic typing that people put up, I showed how it ] would typically be implemented (directly) in C. I hope you can see the ] difference between this and what you're talking about. If C had dynamic typing, we would be able to do this: void doFooToThingsInList(list) list_t* list; { void* nextThingInList; while(nextThingInList = list->getNextThing()) nextThingInList->foo(&nextThingInList); } However, this is not possible, due to the fact that a void* in C must have a cast applied to it before it can be dereferenced. Therefore, we must do something like the following: ((someType*)nextThingInList)->foo(&nextThingInList); In other words, the *programmer* is responsible for ensuring that the statement ((someType*)nextThingInList)->foo() is valid for the type someType. With dynamic typing, however, this requirement (that the programmer ensures that all statements are type-safe) is no longer a requirement at all. The responsiblity for type-safety is no longer left to the programmer, as there is no requirement that all statements be type-safe. ]]] Am I crazy, or isn't (void *) impossible to indirect? Don't you have ]]] to type-cast it first? Isn't this dynamic typing implemented on top of ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ]]] C? ^^^ ]YES. People are tossing around the term ``dynamic typing'' as if it were ^^^ ]some truly important feature. ``Yeah, Bob, not only does the language ]have *loops*, but it has *dynamic typing*!'' ``Wow! *Dynamic typing*? ]Really?'' NO. It was *not* dynamic typing implemented on top of C. It was an example of what a programmer in a statically typed language has to do in order to accomplish what is (more simply) done with a dynamically typed language. Dynamic typing *is* a truly important feature. It allows a greater degree of code reuse. Dan, if you would take the time to understand the scenario I proposed where one developer provides another developer with classes of objects in a window, the benefits of dynamic typing would be apparent. ]You can implement all real-world EXAMPLES---or, at least, every example ]that's come up in this group---of dynamic typing directly in C. That's You cannot implement the real-world example that I posted earlier directly in C. If you wish, I will post a different real-world example of dynamic typing that cannot be implemented directly in C.