• 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: nil messaging? Is it safe?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nil messaging? Is it safe?


  • Subject: Re: nil messaging? Is it safe?
  • From: Nicholas Riley <email@hidden>
  • Date: Thu, 26 Sep 2002 15:57:29 -0500
  • Mail-followup-to: Gerben Wierda <email@hidden>, email@hidden

On Thu, Sep 26, 2002 at 09:39:21PM +0200, Gerben Wierda wrote:
> Now, I do not understand this. How can the compiler or the runtime
> system know what the message will return? After all, nil has no class,
> so there is no way of knowing the signature of the message (that is, the
> return value).

The compiler keeps track of all available selectors (for all known
classes); for a given selector there can be only one return type. If
the selector is unknown, I think you can only get an object/nil return
type, but I'm not sure.

> I was under the impression that any message sent to nil will just return
> nil and that's it. No harm done. But both statements above do suggest
> something else is going on. So: is it safe to send messages to nil? What
> does the runtime system exactly do with messages like that?

Nothing, just be careful if you use the return value and it's not an
object/pointer type.

--
=Nicholas Riley <email@hidden> | <http://www.uiuc.edu/ph/www/njriley>
Pablo Research Group, Department of Computer Science and
Medical Scholars Program, University of Illinois at Urbana-Champaign
_______________________________________________
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.

  • Follow-Ups:
    • Re: nil messaging? Is it safe?
      • From: Ondra Cada <email@hidden>
    • Re: nil messaging? Is it safe?
      • From: Jonathan Wight <email@hidden>
References: 
 >re: nil messaging... (From: Ando Sonenblick <email@hidden>)
 >nil messaging? Is it safe? (From: Gerben Wierda <email@hidden>)

  • Prev by Date: Re: NSNetService addresses returns empty array
  • Next by Date: Re: NSUndoManager & NSTableView editing
  • Previous by thread: nil messaging? Is it safe?
  • Next by thread: Re: nil messaging? Is it safe?
  • Index(es):
    • Date
    • Thread