bug-gnustep
[Top][All Lists]
Advanced

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

Re: gnustep/base modifications for OSX


From: David Ayers
Subject: Re: gnustep/base modifications for OSX
Date: Tue, 28 Jan 2003 22:46:56 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3a) Gecko/20021212

Richard Frith-Macdonald wrote:

I think in practice, MacOS-X mostly does what I consider the sensible thing ... copies are really shallow ... even though the abstract copy methods are deep and they reserve the right to have concrete classes do anything!

If we adopted the convention that all collection copies are shallow, we could add a few new methods for deep copies.

This sounds sane and I'm all for it, even though the EOControl category in NSArray at first sight suggests the shallowCopy to be the "extension":
http://developer.apple.com/techpubs/webobjects/WebObjects_4.5/System/Library/Frameworks/EOControl.framework/ObjC_classic/Classes/NSArrayAdditions.html#//apple_ref/occ/instm/NSArray%20Additions/shallowCopy

Shallow copies are 'safe' in that they don't cause recursion, and are obviously quicker than deep ones ...
which is why I think that standard behavior should be shallow copy.
The question of how a deep copy would deal with a recursive data structure remains though.

Well, on the one hand there is the concrete "recursive data structure" (i.e. aDictionary1 which contains anArray1 which contains the original aDictionary1) I believe this must resolved at a higher level of abstraction and shouldn't concern base. Either gdl2 already deals with this when copying custom eoobjects using the defininitions of "ownsDestination" in the EORelationships or we're still going to implement it there.) but the more fundamental question is how to implement deepCopy, and I'll interpret this as the remaining question you were referring to.

1. Do we send copy/copyWithZone: and have more or less undefined results on level down? I would be against this, but convince me if you think it's correct.

2. Do we call a potential shallowCopy/shallowCopyWithZone: which could be implemented in the abstract collection classes as AUTORELEASE([[[self class] alloc]initWithCollection: self] and NSObject might implement it by calling copyWithZone: allowing only one level of "deepness".

3. Or should deepCopy also propagate deepCopy/deepCopyWithZone:? and NSObject might implement it by calling copyWithZone: also.

I guess, in the case of a plist structure, if I deepCopy the root object, I would expect a full deepCopy of all the contents. So I'm leaning towards 3. 2. can trivially implemented by any code that needs it.

Cheers,
Dave

PS: If I remember correctly, a lot of gdl2's usage of copy/mutablCopy on collection classes was intended for conversions between mutable and non-mutable counterparts. I'm wondering whether we could/should introduce a shallowMutableCopyWithZone: and define that shallowCopyWithZone: always returns immutable counterparts. I'm not clear on whether a deepMutableCopyWithZone: would also be needed to have a complete defined implementation or whether we're going over board.

I really don't know but I though I'd mention it for the record.






reply via email to

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