[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "multiple inheritence" / behavior

From: Adam Fedor
Subject: Re: "multiple inheritence" / behavior
Date: Fri, 15 Nov 2002 10:24:05 -0700
User-agent: Mozilla/5.0 (X11; U; Linux ppc; en-US; rv:1.1) Gecko/20020905

But I think the problem remains that he has to IMPLEMENT the same code in both classes, which is not only a waste, but could lead to problems if they get out of sync (although I suppose you could play with #ifdef's and multiple compilations of the same file).

Behaviors, however, are one step further. They are a protocol with an implementation. behaviors are used at a fundamental level in gnustep-base, so I think they will continue to be supported in the future (They aren't supported on Darwin with the darwin compiler, though).

As long as you access all instance variables through a method and not directly, there should be no problem using them in classes with different layouts.

Mondragon, Ian wrote:
ooops...don't forget to import the SecretMethods.h file ;-)

-----Original Message-----
From: Mondragon, Ian Sent: Friday, November 15, 2002 10:16 AM
To:     'Manuel Guesdon'; address@hidden
Subject:        RE: "multiple inheritence" / behavior

use a @protocol - that's exactly what they're for.  if you want all of
your classes to respond to everyoneDoThis and everyoneDoThat...

--- SecretMethods.h ---


- (void)everyoneDoThis;
- (void)everyoneDoThat;


--- end ---

then in each of your non-related classes, just declare them like so:

--- WhateverClass.h ---

@interface WhateverClass <SecretMethods>

--- end ---

then implement the methods.

problem solved.  another hoo-rah for objc.

- ian mondragon

-----Original Message-----
From:   Manuel Guesdon [SMTP:address@hidden
Sent:   Friday, November 15, 2002 9:30 AM
To:     address@hidden
Subject:        "multiple inheritence" / behavior

MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: INLINE
Organization: Orange Concept
X-Mailer: Mahogany 0.64 'Sparc', compiled for Linux 2.4.3-12smp i686
Reply-To: address@hidden


I'dl like to have a common set of methods used by different objects but
without letting them inherit from the same class
and without adding a category to one of the common inherited class.
I've seen behavior methods which seems to be what I need but there are
warnings in behavior.h.
So, is there another method to make this ? If not, is behaviour will be
supported for a long time ? Is there any
problem if I add methods by this way in classes which don't have exactly
the same ivars (or ivars order) if I don't use
these ivars directly ?

Thank you .


Discuss-gnustep mailing list

Discuss-gnustep mailing list

Adam Fedor, Digital Optics Corp.      | I'm glad I hate spinach, because
http://www.doc.com                    | if I didn't, I'd eat it, and you
                                      | know how I hate the stuff.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]