bug-gnustep
[Top][All Lists]
Advanced

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

Fwd: NSMutableArray copy does a deep copy


From: Richard Frith-Macdonald
Subject: Fwd: NSMutableArray copy does a deep copy
Date: Thu, 16 Jan 2003 07:52:40 +0000



Begin forwarded message:

From: Richard Frith-Macdonald <richard@brainstorm.co.uk>
Date: Thu Jan 16, 2003  7:49:45  am Europe/London
To: James Knight <foom@fuhm.net>
Subject: Re: NSMutableArray copy does a deep copy


On Tuesday, January 14, 2003, at 11:29  pm, James Knight wrote:

For some reason, NSMutableArray's copyWithZone does a deep copy of the array, calling copy on all it's elements. NSArray does not do this. This makes absolutely no sense at all: the mutability of the array itself has nothing to do with the necessity of copying its elements. If a deep copy is desired, perhaps a deepCopy method would be useful, but it's easy enough to implement in code which needs it.

The same problem occurs with NSMutableDictionary and NSCountedSet.

As a point of reference, MacOSX's implementation does a shallow copy on both classes. Thus, it would seem to me that the current implementation is both incorrect and non-sensical. Is there some reason for it being that way?

It was done that way to be exactly compatible with Apples implementation.

At the time I put together test programs to determine exactly what Apple was doing on their Rhapsody system and in the NeXT OPENSTEP system, and the GNUstep implementation was made to perform exactly the same way (rather than the slightly ambiguously documented way).

When MacOS-X came out initially, mutability/immutability of arrays was broken as they had rewritten that code (badly) ... so I didn't bother even trying to update to match their new implementation.

I didn't realise that later releases of MacOS-X had changed the behavior again.






reply via email to

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