home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.object:3030 comp.lang.eiffel:994
- Newsgroups: comp.object,comp.lang.eiffel
- Path: sparky!uunet!munnari.oz.au!metro!graham
- From: graham@maths.su.oz.au (Graham Matthews)
- Subject: Re: Class methods (was: Re: How to design a data structure library)
- Message-ID: <graham.712283419@galois>
- Sender: graham@maths.su.oz.au
- Nntp-Posting-Host: galois.maths.su.oz.au
- Organization: Sydney University Computing Service, Sydney, NSW, Australia
- References: <1992Jul23.123609.11699@bony1.bony.com> <5618@vexpert.dbai.tuwien.ac.at> <1992Jul27.155428.11825@bony1.bony.com>
- Date: Tue, 28 Jul 1992 00:30:19 GMT
- Lines: 36
-
- (Richard Bielak) writes:
- >Bertrand Meyer and others, suggest that methods of a class can be
- >broken up into "queries" and "commands". "queries" are functions,
- >which do not change the object and "commands" are procedures that do.
- >So in class SET we have:
- > is_element (e : T) : BOOLEAN is -- this is a query
- > ....
- > add_element (e : T) is -- this is a command
- > ....
- > merge (b : SET) is -- adds elements of 'b' into current
- > .... -- this is a command
- >The question is then what is "union"?
- >I want to use it to create new sets - as in a := x.union (c,d). It is
- >not clearly a command - it doesn't modify its object, but it doesn't
- >feel like a query either.
- >I'm proposing that it should be a "creation" method - not a query or
- >command, so that you can write:
- > !!c.union (a,b)
- >which says "create a set which is a union of 'a' and 'b'".
- >This statement clearly shows that a new object is created - this is
- >not immediatly clear if you write c := a.union (a,b) or even
- >c := a.unionWith(b).
- >...richie
-
- Are you really serious about this notation Richie? This means that
- I would have to write integer addition as
-
- !!c.+(6,7);
-
- After all it creates a new integer!
-
- graham
- --
- Graham Matthews And it's true we are immune
- Pure Math, Uni.Sydney, Oz When fact is fiction and T.V. is reality
- graham@maths.su.oz.au
-