Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!batcomputer!cornell!uw-beaver!fluke!ssc-vax!dmg From: dmg@ssc-vax (David M Geary) Newsgroups: comp.object Subject: Re: Type Systems and Dynamic Binding Message-ID: <3810@ssc-bee.ssc-vax.UUCP> Date: 9 Apr 91 15:17:15 GMT References: <1594@optima.cs.arizona.edu> Sender: news@ssc-vax.UUCP Reply-To: dmg@ssc-vax.UUCP (David M Geary) Organization: Boeing Aerospace & Electronics Lines: 81 Dan Bernstein claims to be able to implement dynamic typing on top of C: ] Dan Bernstein ]] David Geary ]]] David Gudeman ]struct {any object; void (*redraw)(); int (*ismouseover)();} *whatsinwindow(); ]] NO. This is *not* an example of dynamic typing implemented on top of C. ]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!). ]]] Well I can't. I've tried pretty hard to find a way to get extensible ]]] dynamic typing in C++, and I don't believe it can be done ... ]]] If you can do this I'd like to see it. I'd like to see it also. Either Dan does not understand dynamic typing, or he has found something which the rest of the world needs to know. Let's take the window example since that was the original context of this discussion: 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 } Admittedly, the same effect can be had (in C++) if developer A ensures that buttons, menus, and icons all have a superclass in common, such as windowThing which has a redraw method. However, that is *not* dynamic typing, that is inheritance - two very different things. 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.