[OGo-GNUstep-Port] gcc 3 warnings
Filip Van Raemdonck
gnustep-port@opengroupware.org
Tue, 22 Jul 2003 09:53:35 +0200
On Sat, Jul 19, 2003 at 01:27:23AM +0200, Helge Hess wrote:
> On Freitag, 18. Juli 2003, at 23:19 Uhr, Filip Van Raemdonck wrote:
> >
> >The first is, where messages are sent which are defined in OGo specific
> >classes, not to use too generic names for these methods so that they
> >don't clash with others.
>
> this would be completely against the Smalltalk idea of ObjC, names
> should be the same if they do similiar things (like -name)
Agreed, though one could say that in that case they should have identical
return types, to make it clear that they really are to do the same thing
when observed from the outside (nomatter how different the internal
implementation may be).
> >The second is typecasting the recievers to the class from which the
> >desired method is.
>
> This is the way to go, even being ugly, I admit :-(
Yes and no. It makes it clear to the compiler what message to use.
Actually, rereading the Objective-C book section on messages and
selectors, this _is_ how it's supposed to be:
"... except for messages sent to statically typed receivers, dynamic
binding requires all implementations of identically named methods to
have the same return type and the same argument types. (Statically
typed receivers are an exception to this rule, since the compiler can
learn about the method implementation from the class type.)"
There is actually also a third solution which might not work in all
cases - reduce the set of included header files to a minimum. Doing
that *may* cause conflicting method signatures disappear from the
compilers view. Then again, maybe not... (and I'm not sure whether
that would even work, given the above, since all message which have
identical names would at runtime still share the same selector)
Regards,
Filip
--
"They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety."
-- Benjamin Franklin