Re: NSDictionary design bug (was: Re: Ugly bug in Foundation, beware!)
Re: NSDictionary design bug (was: Re: Ugly bug in Foundation, beware!)
- Subject: Re: NSDictionary design bug (was: Re: Ugly bug in Foundation, beware!)
- From: Patrick Machielse <email@hidden>
- Date: Mon, 07 Jun 2004 13:04:13 +0200
op 07-06-2004 01:52 schreef Marcel Weiher
>
I am not sure why you (and everyone else??) think you have to explain this to
>
me, because the sample code was constructed to exploit/show this. I thought
>
this was obvious, but obviously not obvious enough.
Pick one:
* You are vastly more intelligent than the rest of the people on the list.
* Your post didn't convey your obvious savvyness.
>
> You should either make a clever isEqual: implementation for MyObject, or heed
>
> the recomendation from the documentation:
>
>
No, I should not have to work around NSDictionary's buggy implementation.
>
Furthermore, what I consider -isEqual: is application-dependent.
You can consider isEqual: whatever you like, as long as you obey the implied
rule:
when b = [a copy] then [b isEqual:a] == YES must hold
I can't find a direct reference to this rule in the documentation of
NSCopying (file an enhancement request?), but I can't think of a reason to
have a 'copy' operation return an object that is _not_ equal.
When you willingly violate this rule, as you do in your example, you really
lose all hope of NSDictionary functioning.
The design bug is in your MyObject class, which creates copies which are not
'equal', not in NSDictionary.
Patrick
---
Hieper Software
w: www.hieper.nl
e: email@hidden
_______________________________________________
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.