Re: checking for non zero before ... (Was Re: semantics of init)
Re: checking for non zero before ... (Was Re: semantics of init)
- Subject: Re: checking for non zero before ... (Was Re: semantics of init)
- From: Joe Osborn <email@hidden>
- Date: Wed, 4 Jun 2003 07:37:13 -0500
On Wednesday, June 4, 2003, at 06:49 AM, Jim Correia wrote:
On Tuesday, June 3, 2003, at 11:22 PM, Andrew Pinski wrote:
You do not need to check if _myString are non NULL (zero) before
sending it a message except for speed reasons.
Or if the method returns a non-ID value, and you plan on using the
return value, since the return value is otherwise undefined.
Jim
For reference, a detailed list of the rules is as follows:
Greg Parker wrote:
The documentation states that a return type of 'id' or 'MyObject *' is
guaranteed to be nil, and any other return type will have some
undefined value. In practice, the messenger sets four bytes' worth of
return value to zero (r3 on ppc), with the following effects:
* id, pointer, int: returns 0 or nil
* float, double: returns some random value
* long long (8 bytes): returns some random value with the 4 least-
significant bytes zero
* structs: returns some random value.
The undocumented zero value for int return probably won't change any
time
soon, because too much code depends on this. Be wary of float, double,
and
long long results, which are definitely not set to zero even though
int is.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.