home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!news.univie.ac.at!blekul11!frmop11!dearn!esoc!kkeyte
- Organisation: European Space Operation Centre (E.S.O.C)
- Date: Saturday, 12 Sep 1992 15:05:12 CET
- From: Karl Keyte <KKEYTE@ESOC.BITNET>
- Message-ID: <92256.150512KKEYTE@ESOC.BITNET>
- Newsgroups: comp.lang.c++
- Subject: Re: Answers on a postcard...
- References: <92254.104002KKEYTE@ESOC.BITNET> <1992Sep10.174914.838@taumet.com>
- <92255.112151KKEYTE@ESOC.BITNET> <1992Sep11.174716.3699@taumet.com>
- Lines: 40
-
- >>The implication of what you say is that it is not possible to overload
- >>operators maintaining the correct functionality of the operator. This
- >>indeed means that precedence in overloaded operators cannot be maintained
- >>if all operands are simply passed as arguments to the function implementing
- >>the operator functionality and evaluated in a language independent order.
- >>Imagine commonly used "chain" operators such as && and ::.
- >
- >The only other overloadable operator which imposes order of evaluation
- >is the comma. Originally it was not overloadable, since there seemed
- >to be no good reason to allow it. It looks like we have found a
- >good reason to disallow it, namely that the implied order of
- >evaluation no longer holds. (Too bad it is so hard to stuff the
- >genie back into the bottle.)
- >
-
- I accept what you're saying but my point is this... In overloading, for
- example, the '+' operator for one of my own classes, I would try to provide
- functionality which fits with the usual understanding of the operator. In
- providing '+' for "strings" I would hope to offer concatenation rather than
- truncation with the '+' operator. That works quite well. If I require
- something which is unrelated to any operator I would rather not overload
- but provide a member function. This means, when I overload an operator
- it is because I want to perform some function which is similar (in concept)
- to the original operator. I also want the user (programmer) to be able to
- use the operator in the usual fashion.
-
- To do what I have just described with the comma-operator in C++ is not
- possible. Of course I can overload it to do something completely unrelated
- to what one understands of the operator, but to do something "special" and
- leave its order of evaluation the same as the operator is not possible.
- I feel that this is an oversight rather than expected behaviour. I can't
- find any reference to the specifics of overloading the comma-operator in
- any of the reference works, other than that it is possible to overload.
-
- You mention that there seems no sensible reason to allow its overloading. I
- see no sensible reason to "disallow" it unless the order of evaluation
- problem cannot be rectified, which of course it could. At present I feel
- the situation is not clear enough in this area.
-
- Karl
-