Re: nil in NSArray

2008-12-15 Thread Alex Horovitz


On Dec 13, 2008, at 7:40 PM, Mike Schrag wrote:

OK -- So what's the official reason why you aren't allowed to put a  
nil into an Objective-C NSArray?  It seems like a pretty silly  
restriction to me ...


Mike - I asked Steve Naroff for you...

On Dec 15, 2008, at 10:00 AM, steve naroff wrote:


On Dec 13, 2008, at 7:52 PM, Alex Horovitz wrote:

Thoughts?



Here's Ali Ozer's perspective...

If you allow nils in collections, then you can't tell from calls  
such as objectForKey: or objectEqualToObject: whether the nil return  
indicates failure or a hit on nil. So you have to have another  
sentinel, which is what the lower level APIs (NSHashTable,  
NSMapTable) do, with the added complexity in API of course.


Sounds like the kit folks chose to keep the API simpler (at the cost  
of not allowing 'nil'). Not super compelling, but a design made a  
long time ago...


snaroff



-A

Alex
~~
Alex Horovitz
Chief Technology Officer
The Brookeside Group, Inc.

524 Main Street
Acton, MA 01720
(o) 978.266.9876 x225
(c) 978.808.0808
(f) 978.266.1555
ahorov...@brookeside.com
www.brookeside.com

The Brookeside Group, Inc. - Loyalty MattersTM.

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

nil in NSArray

2008-12-13 Thread Mike Schrag
OK -- So what's the official reason why you aren't allowed to put a  
nil into an Objective-C NSArray?  It seems like a pretty silly  
restriction to me ...


ms

___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: nil in NSArray

2008-12-13 Thread Clark Mueller

Cocoa Foundation has NSNull as JavaFoundation does, why not use that?
The NSNull class defines a singleton object used to represent null  
values in collection objects (which don’t allow nil values).




Clark

On 13-Dec-08, at 4:40 PM, Mike Schrag wrote:

OK -- So what's the official reason why you aren't allowed to put a  
nil into an Objective-C NSArray?  It seems like a pretty silly  
restriction to me ...


ms

___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/cpmueller%40mac.com

This email sent to cpmuel...@mac.com


___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: nil in NSArray

2008-12-13 Thread Mike Schrag

Cocoa Foundation has NSNull as JavaFoundation does, why not use that?
The NSNull class defines a singleton object used to represent null  
values in collection objects (which don’t allow nil values).
... because it's a lame hack :) ?  I know there are workarounds, but  
in 2008, I don't expect junk like that.  I can't imagine it's really a  
null-terminated array in NSArray's implementation.  They almost  
certainly track count as an int separately, and therefore wouldn't  
need null-termination of the internal array.


ms
___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: nil in NSArray

2008-12-13 Thread Chuck Hill


On Dec 13, 2008, at 4:40 PM, Mike Schrag wrote:

OK -- So what's the official reason why you aren't allowed to put a  
nil into an Objective-C NSArray?  It seems like a pretty silly  
restriction to me ...


Tradition?  That is all that I can think of.

Chuck


--
Chuck Hill Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their  
overall knowledge of WebObjects or who are trying to solve specific  
problems.

http://www.global-village.net/products/practical_webobjects






___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: nil in NSArray

2008-12-13 Thread Clark Mueller

Oh, I see. You wanted explanation. :-)

I suppose that if nothing else it would be for historical reasons, but  
I was under the impression there was a point to NSNull. Specifically,  
aren't there scenarios where you might want to distinguish a null  
pointer from querying for the presence of a null value?


For example, in WO, if you're using an NSDictionary bindings for  
query bindings, you might want to query for some attribute  
myAttribute that equals NULL in your database, so you would do  
something like bindings.setObjectForKey(NSKeyValueCoding.NullValue,  
myAttribute). So when EOF is constructing the qualifier, it knows  
that it should produce WHERE my_attribute = NULL, but that when  
bindings.objectForKey(myOtherAttribute) is null (as in a null  
pointer), it knows that's not an attribute you want to qualify on.


Am I wrong? Wouldn't the same apply to some scenarios in Cocoa in the  
context of Core Data? Or certainly, to the defunct Objective-C version  
of WO?


Clark

On 13-Dec-08, at 5:58 PM, Mike Schrag wrote:


Cocoa Foundation has NSNull as JavaFoundation does, why not use that?
The NSNull class defines a singleton object used to represent null  
values in collection objects (which don’t allow nil values).
... because it's a lame hack :) ?  I know there are workarounds, but  
in 2008, I don't expect junk like that.  I can't imagine it's really  
a null-terminated array in NSArray's implementation.  They almost  
certainly track count as an int separately, and therefore wouldn't  
need null-termination of the internal array.


ms
___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/cpmueller%40mac.com

This email sent to cpmuel...@mac.com


___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: nil in NSArray

2008-12-13 Thread Clark Mueller
And yeah... I guess that example is specific to NSDictionary. In  
NSArray's case... something to do with NSKeyValueCoding conformance  
maybe?


Clark

On 13-Dec-08, at 6:39 PM, Clark Mueller wrote:


Oh, I see. You wanted explanation. :-)

I suppose that if nothing else it would be for historical reasons,  
but I was under the impression there was a point to NSNull.  
Specifically, aren't there scenarios where you might want to  
distinguish a null pointer from querying for the presence of a  
null value?


For example, in WO, if you're using an NSDictionary bindings for  
query bindings, you might want to query for some attribute  
myAttribute that equals NULL in your database, so you would do  
something like bindings.setObjectForKey(NSKeyValueCoding.NullValue,  
myAttribute). So when EOF is constructing the qualifier, it knows  
that it should produce WHERE my_attribute = NULL, but that when  
bindings.objectForKey(myOtherAttribute) is null (as in a null  
pointer), it knows that's not an attribute you want to qualify on.


Am I wrong? Wouldn't the same apply to some scenarios in Cocoa in  
the context of Core Data? Or certainly, to the defunct Objective-C  
version of WO?


Clark

On 13-Dec-08, at 5:58 PM, Mike Schrag wrote:

Cocoa Foundation has NSNull as JavaFoundation does, why not use  
that?
The NSNull class defines a singleton object used to represent  
null values in collection objects (which don’t allow nil values).
... because it's a lame hack :) ?  I know there are workarounds,  
but in 2008, I don't expect junk like that.  I can't imagine it's  
really a null-terminated array in NSArray's implementation.  They  
almost certainly track count as an int separately, and therefore  
wouldn't need null-termination of the internal array.


ms
___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/cpmueller%40mac.com

This email sent to cpmuel...@mac.com


___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/cpmueller%40mac.com

This email sent to cpmuel...@mac.com


___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com