On Wed, Aug 20, 2008 at 7:15 PM, Torsten Curdt <[EMAIL PROTECTED]> wrote: > I guess my questions wasn't phrased correctly. The point was more: is 'nil' > really the equivalent of 0 or NULL. > > There was a common perception that NULL is not really the same as nil. But > seems like in the end it really is (void*)0.
As always, it's helpful to follow the rabbit down his hole and see where he goes. On stddef:403 we find this: #define NULL ((void *)0) So that's what NULL really is, at least on my system. Now, on objc/objc.h:57 we find this: #define nil __DARWIN_NULL /* id of Nil instance */ Well, we have to follow that a bit further. But here we are, on sys/_types.h:91: #define __DARWIN_NULL ((void *)0) So not only are NULL and nil equivalent, they are the *same thing*. (Now, they don't have to be. As I recall, NULL can just be a plain integer 0 as well. But they do have to be equivalent, and it just so happens that they are identical even though they don't need to be.) Now, that's not to say that they're semantically equivalent. NULL is meant to be any pointer type, whereas nil is meant to be for objects only (and Nil, capital N, is meant to be for the Class type). So it's best to keep that separation in your code to better indicate what's truly going on. After all, that's why nil (and Nil) exist at all, rather than just reusing NULL. But in the end they are ultimately the same. Mike _______________________________________________ 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]