Re: Ugly bug in Foundation, beware!
Re: Ugly bug in Foundation, beware!
- Subject: Re: Ugly bug in Foundation, beware!
- From: Ondra Cada <email@hidden>
- Date: Thu, 3 Jun 2004 19:01:53 +0200
Nicko,
On 3.6.2004, at 18:39, Nicko van Someren wrote:
>
> Any other arguments?
>
>
Actually I think the one that Marco made at the top, that only you
>
know when it is appropriate to deep copy the data structures used by
>
your program,
Ahem... well, as I wrote to Marco, paint me a newbie, and tell me: what
is a shallow immutable copy of a property list good for?
A deep immutable copy makes my own immutable snapshot of the complete
structure: many great usages(*). A shallow mutable copy makes, well, a
mutable copy--an array with the same contents which I can subsequently
change: many great usages. Shallow immutable copy? In twenty-odd years
of object-oriented programming I haven't bumped into a reasonable usage
of that. What would it be?
(Let me repeat that for dictionary keys and similar usage it is quite
bad, for it forces you to ignore the contained objects when computing
hash, which makes your dictionaries so inefficient there is hardly a
point of using them at all--a binary-searched array would be much
better!)
(*) archiving is not an option, for it is extremely memory-inefficient.
Mind that deep immutable copy copies mutable objects only, but *shares*
all the immutable parts of the structure; archiving would make a copy
of them too.
>
coupled with my previous point that only you know when it is
>
_possible_ to deep copy your data
Sorry, this is wrong. It is possible (and actually pretty easy) to
determine that programmatically--basically, you check whether the
objects conform to NSCopying.
---
Ondra Hada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.