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

  1. Xref: sparky comp.object:3030 comp.lang.eiffel:994
  2. Newsgroups: comp.object,comp.lang.eiffel
  3. Path: sparky!uunet!munnari.oz.au!metro!graham
  4. From: graham@maths.su.oz.au (Graham Matthews)
  5. Subject: Re: Class methods (was: Re: How to design a data structure library)
  6. Message-ID: <graham.712283419@galois>
  7. Sender: graham@maths.su.oz.au
  8. Nntp-Posting-Host: galois.maths.su.oz.au
  9. Organization: Sydney University Computing Service, Sydney, NSW, Australia
  10. References: <1992Jul23.123609.11699@bony1.bony.com> <5618@vexpert.dbai.tuwien.ac.at> <1992Jul27.155428.11825@bony1.bony.com>
  11. Date: Tue, 28 Jul 1992 00:30:19 GMT
  12. Lines: 36
  13.  
  14. (Richard Bielak) writes:
  15. >Bertrand Meyer and others, suggest that methods of a class can be
  16. >broken up into "queries" and "commands". "queries" are functions,
  17. >which do not change the object and "commands" are procedures that do.
  18. >So in class SET we have:
  19. >     is_element (e : T) : BOOLEAN is  -- this is a query
  20. >         ....
  21. >     add_element (e : T) is           -- this is a command
  22. >         ....
  23. >     merge (b : SET) is               -- adds elements of 'b' into current
  24. >         ....                         -- this is a command
  25. >The question is then what is "union"? 
  26. >I want to use it to create new sets - as in a := x.union (c,d). It is
  27. >not clearly a command - it doesn't modify its object, but it doesn't
  28. >feel like a query either.
  29. >I'm proposing that it should be a "creation" method - not a query or
  30. >command, so that you can write:
  31. >     !!c.union (a,b)
  32. >which says "create a set which is a union of 'a' and 'b'". 
  33. >This statement clearly shows that a new object is created - this is
  34. >not immediatly clear if you write c := a.union (a,b) or even 
  35. >c := a.unionWith(b).
  36. >...richie
  37.  
  38. Are you really serious about this notation Richie? This means that
  39. I would have to write integer addition as
  40.  
  41.     !!c.+(6,7);
  42.  
  43. After all it creates a new integer!
  44.  
  45. graham
  46. --
  47. Graham Matthews                 And it's true we are immune
  48. Pure Math, Uni.Sydney, Oz       When fact is fiction and T.V. is reality
  49. graham@maths.su.oz.au
  50.