home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / next / programm / 5990 < prev    next >
Encoding:
Internet Message Format  |  1992-09-07  |  1.7 KB

  1. Path: sparky!uunet!olivea!decwrl!rosie!next.com
  2. From: ngervae@next.com (Nik Gervae)
  3. Newsgroups: comp.sys.next.programmer
  4. Subject: Re: Multiple init: functions defined
  5. Message-ID: <4925@rosie.NeXT.COM>
  6. Date: 3 Sep 92 23:57:06 GMT
  7. References: <3575@richsun.cpg.trs.reuter.com>
  8. Sender: news@NeXT.COM
  9. Lines: 35
  10.  
  11. In article <3575@richsun.cpg.trs.reuter.com> jack@richsun.cpg.trs.reuter.com  
  12. (Jack Gidding) writes:
  13. > Hmmmm..... this is really strange and very undesired behavior from
  14. > Objective-C.
  15. > When I include the header files from two different classes into a third  
  16. > class, and each of the included classes have a single init: method defined,  
  17. > I get messages similar to the following:
  18. > main2.m:18: warning: multiple declarations for method `init:'
  19. > /Clib/RP.h:32: using `-init:(int )pSize'
  20. > /Clib/RS.h:31: also found `-init:(OBJPTR )s'
  21. > Why is this happening??? Sometimes it tells me that it resolved which init to  
  22. > use, sometimes not, and sometimes it resolves it to the wrong init:.
  23.  
  24. [...]
  25.  
  26. > So, why is it telling me that it is using one method or another...shouldn't  
  27. > this be left up until run-time? 
  28.  
  29. It's happening because the two init: methods are declared with different
  30. argument *types*: one is an int and the other is an OBJPTR. This is a
  31. Bad Thing. If you can statically type the object receiving the init:
  32. message, the compiler can determine which one to use, and make sure
  33. that a bad type conversion doesn't get applied. You don't want a bad
  34. type conversion to get applied, because squishing a signed long int to
  35. an unsigned char (for example) is likely to result in an error....
  36.  
  37. --
  38. Nik Gervae
  39. Software Publications, NeXT Computer, Inc.
  40. ngervae@next.com
  41. [[[[NXDisclaimer alloc] init] disclaim] free];
  42.