Thanks for the insight into this. Some subtle stuff here.

On 8 Dec 2008, at 21:54, Bill Bumgarner wrote:

On Dec 8, 2008, at 1:43 PM, [EMAIL PROTECTED] wrote:
This decisions was purposeful, explicit, and intentional.
I find this an interesting point. Why was such a decision made? It seems counter intuitive.


Performance

An NSMutableDictionary instance can be returned from a method declared as returning (NSDictionary*) without risk that the client is going to go and change the contents behind your back. If "test for mutability" were common, then all kinds of methods across the 'kits would have to -copy the return value and, potentially, deeply.

Is this a bit like the emperor's new clothes?
As long as everyone says its an NSDictionary then it matters not if its an NSMutableDictionary!
A sort of mutually agreed insurance.
Simplicity

What does "mutable" even mean in the case of a collection? If an NSArray of NSDictionaries is "mutable", does that also mean the NSDictionaries contained within are mutable? The current design point is that pretty much everything is immutable unless (a) you specifically created a mutable data structure or (b) the 'kit explicitly returned a mutable data structure.
This reminds me of the memory retain/release rules (if you alloc it you release it etc). If these points aren't already in the docs already then they wouldn't be out of place there.

Reliability

Having lots of "if (mutable) this else that" decision points would reduce the reliability of code in that it would increase the testing load. Example: Unit tests would have to explicitly test the code for both the immutable vs. mutable variants. And that doesn't consider the "mutable container vs. immutable contents" potential myriad of combinations.

b.bum

Jonathan Mitchell

Central Conscious Unit
http://www.mugginsoft.com




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to