Re: !foo vs foo == nil
Re: !foo vs foo == nil
- Subject: Re: !foo vs foo == nil
- From: "Shawn Erickson" <email@hidden>
- Date: Thu, 21 Aug 2008 13:11:26 -0700
On Thu, Aug 21, 2008 at 12:45 PM, Jim Correia <email@hidden> wrote:
> For the sake of completeness (I know Marcel knows the rule), if you are
> using the return value of a message send, the value will be undefined
> depending on return type when sending a message to nil. See the runtime
> documentation for details.
As of the 10.5 runtime the zero value guarantee is more well defined
(aka review the latest and prior documentation)...
--- 10.5 ---
- If the method returns an object, any pointer type, any integer
scalar of size less than or equal to sizeof(void*), a float, a double,
a long double, or a long long, then a message sent to nil returns 0.
- If the method returns a struct, as defined by the Mac OS X ABI
Function Call Guide to be returned in registers, then a message sent
to nil returns 0.0 for every field in the data structure. Other struct
data types will not be filled with zeros.
- If the method returns anything other than the aforementioned value
types the return value of a message sent to nil is undefined.
--- older ---
A message to nil also is valid, as long as the message returns an
object, any pointer type, void, or any integer scalar of size less
than or equal to sizeof(void*); if it does, a message sent to nil
returns nil. If the message sent to nil returns anything other than
the aforementioned value types (for example, if it returns any struct
type, any floating-point type, or any vector type) the return value is
undefined. You should therefore not rely on the return value of
messages sent to nil unless the method's return type is an object, any
pointer type, or any integer scalar of size less than or equal to
sizeof(void*):
-Shawn
_______________________________________________
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