Article View: comp.sys.next.programmer
Article #747Re: Multiple init: functions defined
From: Nik Gervae
Date: Thu, 03 Sep 1992 23:57
Date: Thu, 03 Sep 1992 23:57
35 lines
1790 bytes
1790 bytes
In article <3575@richsun.cpg.trs.reuter.com> jack@richsun.cpg.trs.reuter.com (Jack Gidding) writes: > > Hmmmm..... this is really strange and very undesired behavior from > Objective-C. > When I include the header files from two different classes into a third > class, and each of the included classes have a single init: method defined, > I get messages similar to the following: > > main2.m:18: warning: multiple declarations for method `init:' > /Clib/RP.h:32: using `-init:(int )pSize' > /Clib/RS.h:31: also found `-init:(OBJPTR )s' > > Why is this happening??? Sometimes it tells me that it resolved which init to > use, sometimes not, and sometimes it resolves it to the wrong init:. [...] > So, why is it telling me that it is using one method or another...shouldn't > this be left up until run-time? > It's happening because the two init: methods are declared with different argument *types*: one is an int and the other is an OBJPTR. This is a Bad Thing. If you can statically type the object receiving the init: message, the compiler can determine which one to use, and make sure that a bad type conversion doesn't get applied. You don't want a bad type conversion to get applied, because squishing a signed long int to an unsigned char (for example) is likely to result in an error.... -- Nik Gervae Software Publications, NeXT Computer, Inc. ngervae@next.com [[[[NXDisclaimer alloc] init] disclaim] free];
Technical Details
Message-ID:
<4925@rosie.NeXT.COM>Path:
arc1-ca.pugleaf.net!sparky!uunet!olivea!decwrl!rosie!next.comReferences:
<3575@richsun.cpg.trs.reuter.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!olivea!decwrl!rosie!next.com From: ngervae@next.com (Nik Gervae) Newsgroups: comp.sys.next.programmer Subject: Re: Multiple init: functions defined Message-ID: <4925@rosie.NeXT.COM> Date: 3 Sep 92 23:57:06 GMT References: <3575@richsun.cpg.trs.reuter.com> Sender: news@NeXT.COM Lines: 35