On Tuesday, January 28, 2003, at 09:46  pm, David Ayers wrote:

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.
I think a basic copy would be a shallow copy.

For a truly deep copy, you would just use NSArchiver/NSUnarchiver to
duplicate the entire data structure.

Anything else, you probably have to implement yourself on a class by class basis.

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 think the standard copy (shallow) does the job of making a collection immutable ... but it doesn't make its contents immutable.
There is nothing I can think of in the API which will make an entire data structure immutable (except for property lists).



_______________________________________________
Bug-gnustep mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-gnustep


Reply via email to