home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.object:2989 comp.lang.eiffel:982
- Path: sparky!uunet!email!vexpert.dbai.tuwien.ac.at!mst
- From: mst@vexpert.dbai.tuwien.ac.at (Markus Stumptner)
- Newsgroups: comp.object,comp.lang.eiffel
- Subject: Re: Class methods (was: Re: How to design a data structure library)
- Message-ID: <5618@vexpert.dbai.tuwien.ac.at>
- Date: 24 Jul 92 10:58:49 GMT
- References: <1992Jul23.123609.11699@bony1.bony.com>
- Organization: DB and ES Subdivision, TU Vienna
- Lines: 33
-
- From article <1992Jul23.123609.11699@bony1.bony.com>, by richieb@bony1.bony.com (Richard Bielak):
- > The interesting question is which class should the routine "union" be
- > in? If a, b, and c are of type SET and "union" is a feature of SET,
- > then we have:
-
- > c := a.union(a,b);
-
- No. "Binary operator" means that the receiver is one of the
- arguments. With explicit binary operators (as in C++ or Smalltalk),
- you would write (if "+" expresses union)
-
- c := a + b
-
- That way, "+" is a message declared for sets, and used on sets. If
- you want a named message, you would write
-
- c := a.union(b)
-
- (Still looks odd, but lacks that redundant third parameter)
-
- > In Smalltalk lingo, "union" should be a "class method". The essence of
- > a class method is that it can be invoked when the object of the given
- > class does not exist yet.
-
- 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.
-
- --
- Markus Stumptner mst@vexpert.dbai.tuwien.ac.at
- University of Technology Vienna vexpert!mst@relay.eu.net
- Paniglg. 16, A-1040 Vienna, Austria ...mcsun!vexpert!mst
-