How to squeeze Multiple Inheritance into Squeak ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

How to squeeze Multiple Inheritance into Squeak ?

Warakorn Paphrawat
Squeak does not support multiple inheritance.

Sadly enough the possibility of Multiple Inheritance in Squeak would greatly benefit me in my current Squeak project ?

What would you suggest to squeeze some sort of Multiple Inheritance into Squeak ?

- C-like Macros / or some kind of automation
- Traits
- some other possibilities

What is your experience ?


The idea to design my system better and introduce more abstraction is valid, but  I still would like to stick Multiple Inheritance.


Want to start your own business? Learn how on Yahoo! Small Business.
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: How to squeeze Multiple Inheritance into Squeak ?

Michael Haupt-3
Hi Warakom,

On 11/13/06, Warakorn Paphrawat <[hidden email]> wrote:
> Sadly enough the possibility of Multiple Inheritance in Squeak would greatly
> benefit me in my current Squeak project ?

what exactly is the characteristic in your project that imposes this
requirement on it? Why do you need multiple inheritance? What would
you use it for?

I'd recomment looking at traits first, but without knowing what
exactly you are trying to achieve, I cannot say much more. :-)

Best,

Michael
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: How to squeeze Multiple Inheritance into Squeak ?

Michael Gorsuch
Here's an idea:

I have a Person class, but I need him to inherit traits that the Human class has and the Ninja class has.

Is that sufficient?

On 11/13/06, Michael Haupt <[hidden email]> wrote:
Hi Warakom,

On 11/13/06, Warakorn Paphrawat <[hidden email]> wrote:
> Sadly enough the possibility of Multiple Inheritance in Squeak would greatly
> benefit me in my current Squeak project ?

what exactly is the characteristic in your project that imposes this
requirement on it? Why do you need multiple inheritance? What would
you use it for?

I'd recomment looking at traits first, but without knowing what
exactly you are trying to achieve, I cannot say much more. :-)

Best,

Michael
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

RE: How to squeeze Multiple Inheritance into Squeak ?

Ramon Leon-5
>
> Here's an idea:
>
> I have a Person class, but I need him to inherit traits that
> the Human class has and the Ninja class has.
>
> Is that sufficient?
>
>

"I need him to inherit 'traits' that the Human"

This is what "Traits" are for...  Traits were meant to supercede multiple
inheritance.

Ramon Leon
http://onsmalltalk.com 

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: How to squeeze Multiple Inheritance into Squeak ?

Michael Gorsuch
I obviously have much to learn.  Thanks!

On 11/13/06, Ramon Leon <[hidden email]> wrote:
>
> Here's an idea:
>
> I have a Person class, but I need him to inherit traits that
> the Human class has and the Ninja class has.
>
> Is that sufficient?
>
>

"I need him to inherit 'traits' that the Human"

This is what "Traits" are for...  Traits were meant to supercede multiple
inheritance.

Ramon Leon
http://onsmalltalk.com

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

RE: How to squeeze Multiple Inheritance into Squeak ?

Ron Teitelbaum
In reply to this post by Michael Gorsuch

There are some lightweight ways of handling this using roles.

 

Person

            instanceVariables: roles

 

aPerson roles add: Human new; add: Ninja new.

 

There are a number of roles implementations.  One based on doesNotUnderstand which runs through the roles collection and passes the called but not understandable message to each instance.  Some implementations will return a collection of responses if multiple roles answer the same message, and this can get kinda tricky if you don’t know how to watch for it.  You can also define a specific interface to your methods by specifically implementing your methods on Person to look for a role before forwarding the method and handling the call if it does not.

 

For Example:

 

Person >> killSilently

            aPerson hasNinjaRole ifTrue: [^self ninjaRole killSilently].

            aPerson hasHumanRole ifTrue: [^self humanRole killSilently].

            aPerson handleKillingRequestWithMoreSleepAndExercise.

 

Ninja >> killSilently

            “walk on rice paper leaving no trace then you will be ready”

            self doSilentKilling

 

Human >> killSilently

            “humanity wins”

            self tryToKill.

            self goToPoliceStation.

            self confess.

 

I’m not saying I like roles.  I just thought I’d mention more options.

 

Ron Teitelbaum

President / Principal Software Engineer

US Medical Record Specialists

[hidden email]

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Michael Gorsuch
Sent: Monday, November 13, 2006 3:56 PM
To: A friendly place to get answers to even the most basic questions aboutSqueak.
Subject: Re: [Newbies] How to squeeze Multiple Inheritance into Squeak ?

 

Here's an idea:

I have a Person class, but I need him to inherit traits that the Human class has and the Ninja class has.

Is that sufficient?

On 11/13/06, Michael Haupt <[hidden email]> wrote:

Hi Warakom,

On 11/13/06, Warakorn Paphrawat <[hidden email]> wrote:
> Sadly enough the possibility of Multiple Inheritance in Squeak would greatly
> benefit me in my current Squeak project ?

what exactly is the characteristic in your project that imposes this
requirement on it? Why do you need multiple inheritance? What would
you use it for?

I'd recomment looking at traits first, but without knowing what
exactly you are trying to achieve, I cannot say much more. :-)

Best,

Michael
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

 


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: How to squeeze Multiple Inheritance into Squeak ?

Patty Gadegast
In reply to this post by Warakorn Paphrawat
Hi Warakorn,

maybe it is a little bit late now, for a nice answer, but I will do it
anyway.

You want multiple inheritance? Why? Usually multiple inheritance is not
necessary at all.

Objects communicate via messages, and we have only objects in Squeak! In
my mind the only idea behind having inheritance is, you don't want to
code the same things again and again. So you can create generic objects
that implement the functionalities, several Objects might use. I think
that's clear. I red that your object should understand all the messages
a "human-object" understands and a "ninja-object understands", ok, thats
fine. Now I have 2 suggestions:
1. Isn't a ninja object a kind of human object, (if you use your common
sense, don't think only in terms of your program, please). So you could
inherit the ninja class (object) from the human class. Your new object
would be inherited from this ninja class, which is a human class and
would understand all messages, both do understand. But ok, this
structure is static.
2. You could just teach your object to understand the same messages like
a ninja class, if you would just implement this messages in your object.
But again, this is a static structure.

And here is a third one, that maybe you had in mind. I provides a
dynamic structure. Imagine you would bundle the messages that ninja
objects understand, and you could add this bundle to your object, which
is a human inheritance. I think this is done using traits. I know that
there are traits in squeak or at least some people work on this, but I
don't know how you use this things. There are other people that might be
able to answer this "how" question. I am more on asking the what
question, what exactly do you want to do (the purpose, not the means)?

Best regards,

Patty

Warakorn Paphrawat schrieb:

> Squeak does not support multiple inheritance.
>
> Sadly enough the possibility of Multiple Inheritance in Squeak would
> greatly benefit me in my current Squeak project ?
>
> What would you suggest to squeeze some sort of Multiple Inheritance
> into Squeak ?
>
> - C-like Macros / or some kind of automation
> - Traits
> - some other possibilities
>
> What is your experience ?
>
>
> The idea to design my system better and introduce more abstraction is
> valid, but  I still would like to stick Multiple Inheritance.
>
> ------------------------------------------------------------------------
> Want to start your own business? Learn how on Yahoo! Small Business.
> <http://us.rd.yahoo.com/evt=41244/*http://smallbusiness.yahoo.com/r-index>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>  

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners