Assigning nil to primitives (was Re: Memory management question)
Assigning nil to primitives (was Re: Memory management question)
- Subject: Assigning nil to primitives (was Re: Memory management question)
- From: Tim Lucas <email@hidden>
- Date: Thu, 3 Mar 2005 15:33:58 +1100
On 03/03/2005, at 3:23 PM, Tim Lucas wrote:
The apple docs state:
"A message to nil also is valid, as long as the message returns an
object; if it does, a message sent to nil returns nil. If the message
sent to nil returns anything other than an object, the return value
is undefined."
(Or worse, whilst its safe to send a message to nil, it may not be
safe to
rely on it returning a value, and its an artifact of the runtime that
"usually" sends back a zero. I have not read a definitive language
spec so
I can't say one way or the other)
You *can* rely on it returning nil, just don't go assigning nil to a
primitive.
And if anybody wants to read more about the issue Jeff mentioned,
Wincent Colaiuta has a good post about it on this blog:
http://wincent.com/a/knowledge-base/archives/2004/12/messaging_nil.php
Something to look out for if you are assigning nil's to primitives.
- tim lucas
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden