Re: nil messaging? Is it safe?
Re: nil messaging? Is it safe?
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.