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

  1. Xref: sparky comp.object:3025 comp.lang.eiffel:991
  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: Re: Class methods (was: Re: How to design a data structure library)
  6. Message-ID: <1992Jul27.155428.11825@bony1.bony.com>
  7. Organization: multi-cellular
  8. References: <1992Jul23.123609.11699@bony1.bony.com> <5618@vexpert.dbai.tuwien.ac.at>
  9. Date: Mon, 27 Jul 92 15:54:28 GMT
  10. Lines: 58
  11.  
  12. In article <5618@vexpert.dbai.tuwien.ac.at> mst@vexpert.dbai.tuwien.ac.at (Markus Stumptner) writes:
  13. >From article <1992Jul23.123609.11699@bony1.bony.com>, by richieb@bony1.bony.com (Richard Bielak):
  14.  
  15. [...]
  16.  
  17. >
  18. >Yes, but you already have two sets, a, and b, either of which you can
  19. >send the message to.  Nobody decrees that the receiver of a message
  20. >has to be changed by it, therefore returning c is a valid way to do
  21. >it.
  22. >
  23.  
  24. Bertrand Meyer and others, suggest that methods of a class can be
  25. broken up into "queries" and "commands". "queries" are functions,
  26. which do not change the object and "commands" are procedures that do.
  27.  
  28. So in class SET we have:
  29.  
  30.  
  31.      is_element (e : T) : BOOLEAN is  -- this is a query
  32.          ....
  33.  
  34.      add_element (e : T) is           -- this is a command
  35.          ....
  36.  
  37.      merge (b : SET) is               -- adds elements of 'b' into current
  38.          ....                         -- this is a command
  39.  
  40. The question is then what is "union"? 
  41.  
  42. I want to use it to create new sets - as in a := x.union (c,d). It is
  43. not clearly a command - it doesn't modify its object, but it doesn't
  44. feel like a query either.
  45.  
  46. I'm proposing that it should be a "creation" method - not a query or
  47. command, so that you can write:
  48.  
  49.      !!c.union (a,b)
  50.  
  51. which says "create a set which is a union of 'a' and 'b'". 
  52.  
  53. This statement clearly shows that a new object is created - this is
  54. not immediatly clear if you write c := a.union (a,b) or even 
  55. c := a.unionWith(b).
  56.  
  57.  
  58. ...richie
  59.  
  60.  
  61.  
  62.    
  63.  
  64.  
  65. -- 
  66. * Richie Bielak   (212)-815-3072   | "Your brain is a liquid-cooled parallel  *
  67. * Internet:       richieb@bony.com | super-computer". He pointed to his nose, *
  68. * Bang {uupsi,uunet}!bony1!richieb | "This is the fan."                       *
  69. *    - Strictly my opinions -      |                     - David Chudnovsky - *
  70.