• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [Obj-C] if (self) vs. if (self != nil)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Obj-C] if (self) vs. if (self != nil)


  • Subject: Re: [Obj-C] if (self) vs. if (self != nil)
  • From: Kyle Sluder <email@hidden>
  • Date: Fri, 24 Feb 2012 21:53:10 -0800

On Feb 24, 2012, at 2:07 PM, Scott Ribe <email@hidden> wrote:

> On Feb 24, 2012, at 10:52 AM, Wade Tregaskis wrote:
>
>> Though technically speaking it's true, and is thus an argument for actually using NULL rather than 0
>
> No, it's not such an argument at all. The compiler guarantees that null pointers converted to int become 0,

No it very much doesn't. See my citations.

> that constant 0 assigned to a pointer makes it null,

This is true, but emphasis on the "constant." Assigning a non-constant integer expression to a pointer is implementation-defined, regardless of the value of the integer expression.

> and that null pointer compared to 0 is true

Again, this is dependent on context. Hence the doubt I expressed in my initial post. There is no direct comparison defined between pointer types and integers.

--Kyle Sluder
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: [Obj-C] if (self) vs. if (self != nil)
      • From: Scott Ribe <email@hidden>
References: 
 >[Obj-C] if (self) vs. if (self != nil) (From: Oleg Krupnov <email@hidden>)
 >Re: [Obj-C] if (self) vs. if (self != nil) (From: Wade Tregaskis <email@hidden>)
 >Re: [Obj-C] if (self) vs. if (self != nil) (From: Scott Ribe <email@hidden>)

  • Prev by Date: [Moderator] List is apparently slow relaying messages
  • Next by Date: Re: [Obj-C] if (self) vs. if (self != nil)
  • Previous by thread: Re: [Obj-C] if (self) vs. if (self != nil)
  • Next by thread: Re: [Obj-C] if (self) vs. if (self != nil)
  • Index(es):
    • Date
    • Thread