• 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
Assigning nil to primitives (was Re: Memory management question)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >RE: Memory management question (passing objects to method) (From: Jeff Laing <email@hidden>)
 >Re: Memory management question (passing objects to method) (From: Tim Lucas <email@hidden>)

  • Prev by Date: Re: Memory management question (passing objects to method)
  • Next by Date: Re:How Create Installer for a Cocoa Application
  • Previous by thread: Re: Memory management question (passing objects to method)
  • Next by thread: RE: Memory management question (passing objects to method)
  • Index(es):
    • Date
    • Thread