Re: Ugly bug in Foundation, beware!
Re: Ugly bug in Foundation, beware!
- Subject: Re: Ugly bug in Foundation, beware!
- From: Marcel Weiher <email@hidden>
- Date: Thu, 3 Jun 2004 22:34:41 +0100
Ondra,
On 3 Jun 2004, at 17:01, Ondra Cada wrote:
On 3.6.2004, at 17:48, Marco Scheurer wrote:
This is not a bug: there are cases where you want to make a deep copy,
but they should be rare, and only you know what they are.
Well, paint me a newbie.
Well, in the case of reference semantics vs. value semantics: yes.
What are the archetypal usages for copy in Cocoa? I'd say
- dictionary keys, sets: deep copy needed not to break hash when the
guts change, OR you stick with the current nonsense of all two-item
arrays in one hash, which is a disaster for efficiency;
That is actually a (design) bug. Dictionaries have no business
*whatsoever* copying their keys. For example, it makes it impossible
to use a direct NSObject-derived class with inherited hash/compare: as
a key, but that's only the start.
- undo snapshots: deep copy self-evidently needed, or you undo back to
later state than the proper one;
Huh? The Cocoa undo mechanism doesn't do snapshots, it stores the
message + parameters required to undo the operation, not a snapshot.
- has-a setters: deep-copy self-evidently needed, or your has-a
invisibly turns into a shared object.
There are no such things as "has-a setters", and maybe/hopefully this
will start you thinking about why Marco and I (and many others)
consider auto-releasing accessors (and copying accessors even more so!)
not just not useful, but downright harmful!
The simple fact is that they fool even pretty smart people into
believing things that simply aren't so. And that can never ever be so
in a language like Objective-C, even if you make it sorta/kinda work
for some simple objects.
Cheers,
Marcel
--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
1d480c25f397c4786386135f8e8938e4
_______________________________________________
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.