• 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 18:58:48 -0500
  • Mail-followup-to: Ondra Cada <email@hidden>, email@hidden

On Fri, Sep 27, 2002 at 01:42:20AM +0200, Ondra Cada wrote:
> >for a given selector there can be only one return type.
>
> Wrong. In this case, compiler emits a warning, and uses a randomly(*)
> selected signature of those available for the selector.

Right, that's what I meant by 'only one'... just didn't convey it very well.

> >If
> >the selector is unknown, I think you can only get an object/nil return
> >type, but I'm not sure.
>
> Then don't... well, I think it's vain anyway :(((

Yes, unambiguous selectors are good. That's one thing I originally
hated about ObjC versus Smalltalk, that the selectors are more verbose
(objectAtIndex: or objectForKey: versus at:), but I've come to
appreciate it more as my experience with ObjC has grown. You can be
pretty sure a given selector will only be used for one purpose. Of
course, there are precious few refactoring tools that take advantage
of this; I was spoiled by the Refactoring Browser for VisualWorks. :(

> For an unknown selector, the compiler (emits a warning and) uses a
> signature whose return type (and all argument types, if any) is "id". That
> means such method can safely return anything which is losslessly
> convertable to/from id: in practice, any pointer or int (of the same size
> as pointer).

That means it'd have trouble with structs, though (e.g. NSRect). I
haven't tested to see what would happen.

--
=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.

References: 
 >Re: nil messaging? Is it safe? (From: Nicholas Riley <email@hidden>)
 >Re: nil messaging? Is it safe? (From: Ondra Cada <email@hidden>)

  • Prev by Date: A little OT Help
  • Next by Date: Unusual error message
  • Previous by thread: Re: nil messaging? Is it safe?
  • Next by thread: Re: nil messaging? Is it safe?
  • Index(es):
    • Date
    • Thread