home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.object:3025 comp.lang.eiffel:991
- Newsgroups: comp.object,comp.lang.eiffel
- Path: sparky!uunet!mcsun!sunic!psinntp!psinntp!bony1!richieb
- From: richieb@bony1.bony.com (Richard Bielak)
- Subject: Re: Class methods (was: Re: How to design a data structure library)
- Message-ID: <1992Jul27.155428.11825@bony1.bony.com>
- Organization: multi-cellular
- References: <1992Jul23.123609.11699@bony1.bony.com> <5618@vexpert.dbai.tuwien.ac.at>
- Date: Mon, 27 Jul 92 15:54:28 GMT
- Lines: 58
-
- In article <5618@vexpert.dbai.tuwien.ac.at> mst@vexpert.dbai.tuwien.ac.at (Markus Stumptner) writes:
- >From article <1992Jul23.123609.11699@bony1.bony.com>, by richieb@bony1.bony.com (Richard Bielak):
-
- [...]
-
- >
- >Yes, but you already have two sets, a, and b, either of which you can
- >send the message to. Nobody decrees that the receiver of a message
- >has to be changed by it, therefore returning c is a valid way to do
- >it.
- >
-
- 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
-
-
-
-
-
-
- --
- * Richie Bielak (212)-815-3072 | "Your brain is a liquid-cooled parallel *
- * Internet: richieb@bony.com | super-computer". He pointed to his nose, *
- * Bang {uupsi,uunet}!bony1!richieb | "This is the fan." *
- * - Strictly my opinions - | - David Chudnovsky - *
-