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

  1. Xref: sparky comp.object:2988 comp.lang.eiffel:980
  2. Newsgroups: comp.object,comp.lang.eiffel
  3. Path: sparky!uunet!mcsun!sunic!psinntp!psinntp!bony1!richieb
  4. From: richieb@bony1.bony.com (Richard Bielak)
  5. Subject: Class methods (was: Re: How to design a data structure library)
  6. Message-ID: <1992Jul23.123609.11699@bony1.bony.com>
  7. Organization: multi-cellular
  8. References: <1820@snap> <1992Jul21.124256.17256@bony1.bony.com> <1992Jul22.142916.22115@merlin.hgc.edu>
  9. Date: Thu, 23 Jul 92 12:36:09 GMT
  10. Lines: 42
  11.  
  12. In article <1992Jul22.142916.22115@merlin.hgc.edu> jcm@hgc.edu (James McKim) writes:
  13.  
  14. [...]
  15.  
  16. >It seems to me that Union (I think ISE used 'merge' as the verb 
  17. >form of union), Intersection and Difference (ditto for 'subtract' here)
  18. >are fundamentally binary operations. That is, they're single valued
  19. >functions of two variables, and so should be designed as such.
  20. >Thus I favor the c := a + b or c := union( a, b ) form. I would
  21. >add union, intersection, and difference as a first increment,
  22. >through inheritance, to the minimal SET class.
  23. >
  24.  
  25. The interesting question is which class should the routine "union" be
  26. in?  If a, b, and c are of type SET and "union" is a feature of SET,
  27. then we have:
  28.  
  29.       c := a.union(a,b);
  30.  
  31. Which looks a little odd :-).
  32.  
  33. In Smalltalk lingo, "union" should be a "class method". The essence of
  34. a class method is that it can be invoked when the object of the given
  35. class does not exist yet. In Eiffel terms, a class method is a 
  36. creation routine.
  37.  
  38. Given this, the above call to "union" would be written like this
  39. (using Eiffel 3 syntax):
  40.  
  41.     !!c.union (a,b);
  42.  
  43. Which I think is better. 
  44.  
  45.  
  46.  
  47. ...richie
  48.  
  49. -- 
  50. * Richie Bielak   (212)-815-3072   | "Your brain is a liquid-cooled parallel  *
  51. * Internet:       richieb@bony.com | super-computer". He pointed to his nose, *
  52. * Bang {uupsi,uunet}!bony1!richieb | "This is the fan."                       *
  53. *    - Strictly my opinions -      |                     - David Chudnovsky - *
  54.