| Related articles |
|---|
| From: | Hans-Peter Diettrich <DrDiettrich1@netscape.net> |
| Newsgroups: | comp.compilers |
| Date: | Fri, 13 Apr 2018 10:22:03 +0200 |
| Organization: | Compilers Central |
| References: | <49854345-f940-e82a-5c35-35078c4189d5@gkc.org.uk> 18-03-103 18-03-042 18-03-047 18-03-075 18-03-079 18-03-101 18-04-002 18-04-003 18-04-004 18-04-024 18-04-034 18-04-041 18-04-051 |
| Injection-Info: | gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="99286"; mail-complaints-to="abuse@iecc.com" |
| Keywords: | OOP, design |
| Posted-Date: | 13 Apr 2018 13:18:17 EDT |
Am 13.04.2018 um 02:51 schrieb George Neuner:
> On Thu, 12 Apr 2018 01:09:42 +0200, Hans-Peter Diettrich
> <DrDiettrich1@netscape.net> wrote:
>
>> Am 10.04.2018 um 20:32 schrieb George Neuner:
>>> On Tue, 10 Apr 2018 05:48:43 GMT, anton@mips.complang.tuwien.ac.at
>>> (Anton Ertl) wrote:
>>
>>> Smalltalk had/has single inheritence only, and it's dynamic dispatch
>>> mechanism is very different from that of C++.
>>
>> Isn't *multiple inheritance* one of the features that C++ proved
>> impractical? Which other languages support multiple inheritance?
>
> No. It proved only that C++ wasn't able to accomodate conflicting
> classes effectively. Lisp handles this same problem much more
> effectively, so it isn't a generic fault of MI.
>
> Moreover, most (all?) SI languages implement interfaces (abstract
> classes). Interfaces mainly are a workaround for lacking real MI, so
> why would they do that if it were useless?
Interfaces don't have all the problems arising from multiple
inheritance. I can see only the disadvantage, that duplicate code may be
required to implement the same interface in multiple classes. But see
below...
I've learned to distinguish class aggregation and composition by asking
whether it *is* something, or *has* something. A house *has* a roof, but
it *isn't* a roof, so it does not inherit from a roof class. This way I
never felt a need for multiple inheritance in my programs. But perhaps
outside my restricted experience there exist other needs...
> It often is the case that a subclass has to reimplement something from
> one of its ancestors, and it *might* be the case with MI that there is
> a clash wrt handling something that has to be worked around. But
> using interfaces, it is *guaranteed* that you will have to
> (re)implement not just things that conflict, but everything in the
> interface.
An interface can be implemented by a (class type) component of a class.
Then only the specific dependencies between both classes have to be
implemented explicitly. In Delphi the "implements" keyword implements
such object delegation, in addition to method delegation.
DoDi
Return to the
comp.compilers page.
Search the
comp.compilers archives again.