[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Class clusters: MacOSX/GNUstep differences?
From: |
Ronan Collobert |
Subject: |
Re: Class clusters: MacOSX/GNUstep differences? |
Date: |
Thu, 2 Sep 2004 14:25:05 +0200 (CEST) |
Hello
> Sure, but there are lots of instances where using some or all of the
> initialisers is helpful for the case of the different storage. For
> instance, when an array stores in a linked list, or a sparse array of
> some sort.
I agree.
> Sure, new subclasses add new initialisers which call the designated
> initialiser. It's no more of a nonsense to call -initWithObjects:count:
> than to call -init
Yes. The only problem is that in the NextStep and Cocoa frameworks, it is
specified that you have to call -init in class clusters. As I said before,
I didn't find anything concerning OpenStep. (Is there some hidden docs
about OpenStep somewhere??).
> how you want to design your subclass. The aim of designated
> initialisers is to make as much of the superclass usable by subclasses
> as possible, thus saving effort in many cases ... it's not going to help
> for all cases, but it's never going to be worse than the MacOS-X scheme.
I totally agree. Actually, I'm not sure exactly about the ultimate aim of
GNUstep. I have nothing against adding functionalities. But if it could be
possible to have a complete compatibility (even if it is using
STRICT_MACOS_X compatibility flags at the compilation) with MacOSX, I
think it could be great. After all, I think that a lot of Objective C
developers are coming from MacOSX world.
> > by
> > - (id) initWithObjects: (id*)objects count: (unsigned)count
> > {
> > return nil;
> > }
> I think that looks quite reasonable ... though you would want the
> default implementation of -initWithObjects:count: to return self rather
> than nil wouldn't you?
Yes. Unfortunately, it seems it does not solve completely the problem: in
Cocoa, the designated initializer in class clusters is -init. Therefore,
if for example I create a subclass of NSMutableArray which implements the
initWithCapacity: method
- (id) initWithCapacity:(unsigned int) n
{
if( (self = [super init]) )
{
// my stuff here
}
}
It will work in Cocoa (note: I tried to be sure), but in GNUstep it will
create an infinite loop, because the init method of NSMutableArray call
initWithCapacity (the designated initializer in GNUstep).
Ronan.