For Programmers: Free Programming Magazines  


Home > Archive > Smalltalk > August 2006 > Multiple Inheritance









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Multiple Inheritance
Mani S Kartha

2006-08-17, 8:01 am

Hi,
Smalltalk does not support multiple inheritance...i have heard so.
But smalltalk manages to implement multiple inheritance in other
ways...(may be using MVC ?)...
Can anyone help me with some documents or suggestions?

thanks for any help,

Mani
Jeff M.

2006-08-17, 7:02 pm

I'm hardly a Smalltalk expert. But Smalltalk does have multiple
inheritance through abstract interfaces (called protocols in
Smalltalk). You should be able to see all the protocols that a class
implements through the class browser of whichever implementation you
use.

HTH

Jeff M.

Mani S Kartha wrote:
> Hi,
> Smalltalk does not support multiple inheritance...i have heard so.
> But smalltalk manages to implement multiple inheritance in other
> ways...(may be using MVC ?)...
> Can anyone help me with some documents or suggestions?
>
> thanks for any help,
>
> Mani


Reinout Heeck

2006-08-17, 7:02 pm

Mani S Kartha wrote:
> Hi,
> Smalltalk does not support multiple inheritance...i have heard so.
> But smalltalk manages to implement multiple inheritance in other
> ways...(may be using MVC ?)...



Multiple inheritance is simulated by reimplementing the protocols on
multiple hierarchies. This leads to code duplication...

To avoid the duplication you can use composition instead of inheritance:
plug your objects together from several smaller ones, so those smaller
ones can be reused for composition in other hierarchies.

If you google for 'composition inheritance' you'll get plenty
publications on the subject.



Cheers,

R
-
Isaac Gouy

2006-08-17, 7:02 pm


Mani S Kartha wrote:
> Hi,
> Smalltalk does not support multiple inheritance...i have heard so.
> But smalltalk manages to implement multiple inheritance in other
> ways...(may be using MVC ?)...
> Can anyone help me with some documents or suggestions?
>
> thanks for any help,
>
> Mani


Can you give an example of where you think "smalltalk manages to
implement multiple inheritance in other ways"

Paolo Bonzini

2006-08-18, 4:02 am


> Can you give an example of where you think "smalltalk manages to
> implement multiple inheritance in other ways"


Java only allows multiple inheritance of interfaces for example so,
especially by Java users (don't know about the OP), multiple
inheritance is only used for interface inheritance (with other side
effects, such as the code duplication problem that Reinout mentioned
and that affects Java as much as Smalltalk)

As you know, Smalltalk does not need interface inheritance at all,
because you can just implement the required methods instead. In some
sense, for example, you could say that String "extends"
ArrayedCollection and "implements" Magnitude. So, multiple interface
inheritance is implemented in Smalltalk through untyped variables and
late binding (let me recall that Smalltalk *is* strongly-typed -- it
just checks the typing at run-time rather than compile-time).

Paolo

philippe.marschall@gmail.com

2006-08-18, 4:02 am

Mani S Kartha wrote:
> Hi,
> Smalltalk does not support multiple inheritance...i have heard so.
> But smalltalk manages to implement multiple inheritance in other
> ways...(may be using MVC ?)...
> Can anyone help me with some documents or suggestions?
>
> thanks for any help,
>
> Mani


There are Traits. They are in the current Squeak 3.9 gamma and IIRC
there's also a goodie for VW.

Philippe

Isaac Gouy

2006-08-18, 7:02 pm


Paolo Bonzini wrote:
>
> Java only allows multiple inheritance of interfaces for example so,
> especially by Java users (don't know about the OP), multiple
> inheritance is only used for interface inheritance (with other side
> effects, such as the code duplication problem that Reinout mentioned
> and that affects Java as much as Smalltalk)
>
> As you know, Smalltalk does not need interface inheritance at all,
> because you can just implement the required methods instead. In some
> sense, for example, you could say that String "extends"
> ArrayedCollection and "implements" Magnitude. So, multiple interface
> inheritance is implemented in Smalltalk through untyped variables and
> late binding (let me recall that Smalltalk *is* strongly-typed -- it
> just checks the typing at run-time rather than compile-time).
>
> Paolo


I'm puzzled by these comments - I asked the OP for an example so we
could better understand and better answer the OP's question.

I don't know why we're talking about Java but as you say Java does not
have multiple inheritance. Java has single inheritance - and so does
Smalltalk.

I don't know why we're talking about interface inheritance but I think
the reason "Smalltalk does not need interface inheritance at all" is
because Smalltalk does not provide the language feature that Java calls
an interface.

(Of course there's always
http://www.jot.fm/issues/issue_2002_05/article1 )

Sorry but I think it's nonsense to say that String "extends"
ArrayedCollection and "implements" Magnitude. String does inherit from
ArrayCollection. String does not "implement" Magnitude - String doesn't
even duplicate all the methods defined in Magnitude.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com