home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / object / 3034 < prev    next >
Encoding:
Internet Message Format  |  1992-07-28  |  1.9 KB

  1. Xref: sparky comp.object:3034 comp.lang.eiffel:996
  2. Path: sparky!uunet!mcsun!Germany.EU.net!unido!donald!support
  3. From: support@heeg.de (Support)
  4. Newsgroups: comp.object,comp.lang.eiffel
  5. Subject: Re: Class methods (was: Re: How to design a data structure library)
  6. Message-ID: <1992Jul28.121706.25213@heeg.de>
  7. Date: 28 Jul 92 12:17:06 GMT
  8. References: <1992Jul21.124256.17256@bony1.bony.com> <1992Jul22.142916.22115@merlin.hgc.edu> <1992Jul23.123609.11699@bony1.bony.com>
  9. Organization: Georg Heeg Objektorientierte Systeme, Dortmund, FRG
  10. Lines: 47
  11.  
  12. In article <1992Jul23.123609.11699@bony1.bony.com> richieb@bony1.bony.com (Richard Bielak) writes:
  13. >In article <1992Jul22.142916.22115@merlin.hgc.edu> jcm@hgc.edu (James McKim) writes:
  14. >
  15. >[...]
  16. >
  17. >The interesting question is which class should the routine "union" be
  18. >in?  If a, b, and c are of type SET and "union" is a feature of SET,
  19. >then we have:
  20. >
  21. >      c := a.union(a,b);
  22. >
  23. >Which looks a little odd :-).
  24. >
  25. >In Smalltalk lingo, "union" should be a "class method". The essence of
  26. >a class method is that it can be invoked when the object of the given
  27. >class does not exist yet.
  28.  
  29. Is it? I always thought the essence of a class method is that you can sent it
  30. to a class object... Thus, class methods are nothing special since classes
  31. are nothing special. Just that you don't have them at all in C++ :-)
  32.  
  33. "union" would be a normal instance method, like
  34.  
  35.     c := a union: b.
  36.  
  37. or better:
  38.  
  39.     c := a mergeWith: c
  40.  
  41. or even better:
  42.  
  43.     c := a + b.
  44.  
  45. BTW, in standard Smalltalk there is no "union", "intersection", or "difference".
  46. You'd have to implement it as follows:
  47.  
  48.     c := a addAll: b                "union"
  49.     c := a select: [:each | b includes: each]    "intersection"
  50.     c := a removeAll: b.                "difference"
  51.  
  52. Ciao, Hasko
  53.  
  54. -- 
  55. +-------------------------------------------------------+
  56. | Hasko Heinecke @ Georg Heeg Objektorientierte Systeme |
  57. | I _never_ mean what I say - and nobody else does...   |
  58. +-------------------------------------------------------+
  59.