gnustep-dev
[Top][All Lists]
Advanced

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

mutableCopy in NSArray


From: Thorano
Subject: mutableCopy in NSArray
Date: 16 Mar 2002 23:31:28 +0100

In the current version from the cvs, mutableCopy is only implemented
once in all the hierarchy of NSArray.  The implementation is this one
and it looks wrong to me:

- (id) mutableCopyWithZone: (NSZone*)zone
{
  return [[GSMutableArrayClass allocWithZone: zone] 
    initWithArray: self];
}

because, I thought that the spirit of the NSCopying/NSMutableCopying
protocol was some kind of deep copy and it's not the case here.  The
copy and the original share the same objects.

On the contrary, the copyWithZone method of NSMutableArray is
correctly implemented: It does a copy of the elements.

I would suggest that the [NSArray mutableCopyWithZone] is
exactly the same code as [NSMutableArray copyWithZone].

At least, [NSMutableArray mutableCopyWithZone] should be like
[NSMutableArray copyWithZone]. 

Maybe I'm wrong but I think there is at least an inconsistency between
the implementation copy and mutableCopy for NSMutableArray.

        Frédéric De Jaeger



reply via email to

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