Xref: utzoo comp.lang.misc:7437 comp.object:3191 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!uw-beaver!fluke!ssc-vax!dmg From: dmg@ssc-vax.uucp (David M Geary) Newsgroups: comp.lang.misc,comp.object Subject: Re: Type Systems and Dynamic Binding Message-ID: <3843@ssc-bee.ssc-vax.UUCP> Date: 15 Apr 91 18:21:45 GMT Sender: news@ssc-vax.UUCP Organization: Boeing Aerospace & Electronics Lines: 134 Originator: dmg@ssc-vax ] Dan Bernstein ]] David Geary ]] Dan Bernstein claims to be able to implement dynamic typing on top of C: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ] Although I can implement and have implemented dynamic typing with a ] suitable preprocessor over C, I did not make that claim in the quoted ^^^^^^^^^^^^^^^^^^^^^^^^^^ ] material. Please read a quote before you paraphrase it. ]The original example in question was *presented* as an example of what ]people do with heterogeneous (dynamically typed) lists. I responded with ^^^^^^^^^^^^^^^^ ]the above structure to show how you implement the same thing in C, and ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ]here Geary claims that the example was no longer an example of dynamic ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ]typing. Sheesh. My response: ^^^^^^ Sheesh yourself. Either it *was* an example of dynamic typing or it was *not*. You cannot have it both ways, Dan. I did not claim that your example was *no longer* an example of dynamic typing. I said that your example was *never* an example of dynamic typing. Here, BTW, since you do not want me to paraphrase, is the original article written by Bernstein: ------------------------------------------------------------------------------ % = Darren New %% = Dan Bernstein In article <25655:Mar2803:50:2491@kramden.acf.nyu.edu> (Dan Bernstein) writes: %In article <49087@nigel.ee.udel.edu> new@ee.udel.edu (Darren New) writes: %% 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?'' ----------------------------------------------------------------------------- YES is pretty clear to me. Did you really mean NO? If so, then I misunderstood. ]If you had been keeping up with the discussion in comp.lang.misc, you ]would understand that giving the same name to variables in different ]structures does NOT imply any magical connection between those ]variables. In order to solve your problem as stated, you must make the ]connection explicit, like so (as per my structure as above): Exactly what I was trying to say. Dan Bernstein is *not* implementing dynamic typing on top of C. Since it appeared to me that Bernstein was claiming to be implementing dynamic typing on top of C, I posted the following challenge for Dan: ]]Developer A implements buttons, menus, and icons which are displayable in a ]]window. Developer A provides developer B with: ]] 1) Header files defining structures for buttons, menus and icons. ]] (menu.h, button.h and icon.h). ]] 2) Object modules which implement functionality for each. ]] (menu.o, button.o and icon.o). ]] Menus, buttons, and icons all have a pointer to a redraw function in their ]] structure definition; however, structures for buttons, menus and icons are ]] all different, ie: ]] struct button struct menu ]] { { ]] int x,y,w,h; int x,y,w,h; ]] char* text; int numItems; char** itemText; ]] void (*redraw)(); ]] }; void (*redraw)(); }; ]] struct icon ]] { ]] int x,y,w,h; ]] bitmap* picture; ]] void (*redraw)(); ]] }; ]] Developer A provides a function that returns a list of things in a window ]](things being buttons, menus, and icons). Let's call the function ]]getListOfThingsInWindow(). ]] Now, developer B, given the header files and object modules defined above, ]]processes the list, and displays all items on the list in a fashion similar ]]to: ]] drawWindowThings(window) ]] window_t* window; ]] { ]] list_t* wlist = getListOfThingsInWindow(window); ]] for(each object in wlist) ]] redraw the object ]] } ]] Dan, since you can implement dynamic typing in C, would you please post ]]the *appropriate macros* so that developer B can get his job done, without ]]*in any way* having to modify (recompile) the object modules that are supplied ]]from developer A. Dan replies with: foo->redraw(foo->object); Done. No. Wrong. Not done. Dan is using his own structure instead of those I provided in the example. In the example above, each object in wlist must be a void*. You cannot defererence a void pointer. You cannot implement dynamic typing in C without writing an external preprocessor. Period. BTW, this whole series of postings occurred because I thought that Bernstein claimed to have implemented dynamic typing in C without writing any *external* preprocessor. (As did others in this newsgroup). Since this is impossible to do, I posted the above challenge. Now, Dan seems to be claiming that he never stated he could implement dynamic typing on top of C without writing any *external* preprocessor. If Bernstein's claim today is that he *cannot* implement dynamic typing on top of C withoug writing an external preprocessor, then we are in agreement.