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

  1. Path: sparky!uunet!casey!gaboon!seltd!lerman
  2. From: lerman@seltd.UUCP (Kenneth Lerman)
  3. Newsgroups: comp.sys.next.programmer
  4. Subject: Re: Multiple init: functions defined
  5. Message-ID: <23@seltd.UUCP>
  6. Date: 5 Sep 92 17:30:51 GMT
  7. References: <3575@richsun.cpg.trs.reuter.com>
  8. Reply-To: lerman@seltd.UUCP (Kenneth Lerman)
  9. Organization: Systems Essentials Limited
  10. Lines: 62
  11.  
  12. In article <3575@richsun.cpg.trs.reuter.com> jack@richsun.cpg.trs.reuter.com (Jack Gidding) writes:
  13. ...
  14.  
  15. |When I include the header files from two different classes into a third class,  
  16. |and each of the included classes have a single init: method defined, I get  
  17. |messages similar to the following:
  18. |
  19. |
  20. |main2.m:18: warning: multiple declarations for method `init:'
  21. |/Clib/RP.h:32: using `-init:(int )pSize'
  22. |/Clib/RS.h:31: also found `-init:(OBJPTR )s'
  23.  
  24. The problem is that the compiler doesn't know which init: to use.  It
  25. must either know the type of the receiver or the two methods must have
  26. identical types.
  27.  
  28. |
  29. |
  30. |Why is this happening??? Sometimes it tells me that it resolved which init to  
  31. |use, sometimes not, and sometimes it resolves it to the wrong init:.
  32. |
  33. |
  34. |The code that has the init method is sililar in form to:
  35. |
  36. |    #import <RP.h>    // Both RP and RS have and init: method
  37. |    #import <RS.h>
  38. |
  39. |    id x;
  40. |
  41. |    x = [[RP alloc] init:(int) 5];
  42. |
  43. |id is totally dynamic, and thus it really does not know which init to use....
  44. |
  45. |So, why is it telling me that it is using one method or another...shouldn't  
  46. |this be left up until run-time? 
  47.  
  48. Yes, it should, but the compiler must generate code which is
  49. equivalent to a function call.  To do this, it must know the types of
  50. the arguments.  Since the types are different in this case, it doesn't
  51. know what to generate.
  52.  
  53. |
  54. |
  55. |Am I doing something wrong to cause this?
  56. |
  57. |
  58.  
  59. Yes, you are.
  60.  
  61. |Thanks,
  62. |
  63. |
  64. |Jack Gidding
  65. |jack@richsun.cpg.trs.reuter.com
  66.  
  67. Ken
  68.  
  69. -- 
  70. Kenneth Lerman                  ...!uunet!casey!gaboon!seltd!lerman
  71. Systems Essentials Limited                            (203)426-4430
  72. 55 Main Street
  73. Newtown, CT 06470
  74.