Darren New wrote:
Christopher Smith wrote:
Yeah. I just missed the part where he specifically identified virtual
functions (which don't exist in Smalltalk-80) as the only acceptable
means of achieving this goal.

Well, C++ and Smalltalk are different languages. One could argue that *all* "functions" are "virtual" in Smalltalk. Or that since Smalltalk has no "functions" then it naturally has no "virtual functions". So I'm not really sure what your parenthetical comment was supposed to imply.
Merely that virtual functions are one way of achieving polymorphism, and there are lots of ways of achieving it, some that barely qualify as "dynamic" in any sense.
I don't think he argued that "virtual functions" are the only way to do dynamic dispatch. But it would seem that C++ (as far as I know) only has two ways of doing dynamic binding: virtual functions and function pointers, yes? Is there a third way of having a particular call at a particular line of source code invoke different functions at run time?
Roughly a billion ways. A couple of obvious ones:

1) A combination of templates and overloading provide a way to do what is effectively compile time polymorphism, with the compiler effectively creating branches on whatever types might actually be used.
2) switching on typeid.
3) Having a hashtable of functors (and yes, you can have functors without having function pointers). This can work like a vtable or more like how Smalltalk's message dispatch works.
If you're going to claim you fell out of your chair because Mr. Brown didn't think of pointers to functions, I'm going to be rather incredulous.
I fell out of my chair for two reasons:
1) That Mr. Brown feels there is only one way to achieve dynamic dispatch with C++.
2) That Mr. Brown feels all OO programs require dynamic dispatch.

--Chris

--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to