[Prev][Next][Index][Thread]
Re: Language question, a little bit OT
Stefan Schmiedl wrote:
>> No, C++ does not do the same. Dynamic dispatch happens in C++, as
>> well as Java, Delphi, Python, Perl, Ruby, and Smalltalk, is only
>> based on the class of the object receiving the message.
>
> I am having difficulties in understanding this sentence ...
>
>> C++ is the only one of
>> the listed languages that support multiple inheritance.
>
> Well, in another reply Python was said to do this, too.
> And I know that Common Lisp does have MI.
Yes, I was only referring to the languages I listed in the above
sentence. And apparently I was wrong about Python. CL/CLOS, of course,
has multiple inheritance and multiple dispatch.
>> Some of these
>> languages also support static overloading where the same name can be
>> used for methods with different argument types.
>
> Now I am confused ... "overloading" at compile time, e.g. in Delphi,
> is the mechanism allowing "dynamic dispatch" at run time, no?
I don't know Delphi, but I expect it is very similar in this regard to
C++ and Java.
Overloading is mostly (completely? I'm not sure in the case of
generic-style C++) syntactic sugar and can resolved at compile-time.
Dynamic dispatch in the general case needs to be done at runtime,
because only then the actual type(s) of arguments are known.
>> In the case of C++ this
>> can be used for generic programming -- with the help of some
>> intricate method lookup wizardry behind the scenes.
>
> Is this the template stuff the STL is about?
Yes, it is exemplified by the STL. If you really want to know, get
Andrei Alexandrescu's book "Modern C++ Design"
(http://www.moderncppdesign.com/).
Michael
Follow-Ups:
References: