home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!tmb
- From: tmb@arolla.idiap.ch (Thomas M. Breuel)
- Newsgroups: comp.lang.c++
- Subject: Re: Answers on a postcard...
- Message-ID: <TMB.92Sep11212846@arolla.idiap.ch>
- Date: 12 Sep 92 01:28:46 GMT
- References: <92254.104002KKEYTE@ESOC.BITNET> <1992Sep10.174914.838@taumet.com>
- <92255.112151KKEYTE@ESOC.BITNET>
- Sender: news@ai.mit.edu
- Reply-To: tmb@idiap.ch
- Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
- Perceptive)
- Lines: 32
- In-reply-to: KKEYTE@ESOC.BITNET's message of 11 Sep 92 18:52:30 GMT
-
- In article <92255.112151KKEYTE@ESOC.BITNET> KKEYTE@ESOC.BITNET (Karl Keyte) writes:
-
- >In the expression in parens, it is unspecified whether "x=1" or
- >"x+1" is evaluated first. They are arguments to the "operator,()"
- >function, not the left and right side of a comma-expression. If
- >"x+1" is evaluated first, which is legal, it will use an
- >uninitialized "x.value".
- >
- >Don't write code which depends on unspecified order of evaluation.
-
- 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 ::.
-
- If what is described above is correct, and Mr.Clamage clearly has much
- experience in the area, then I think we have justification for pressing
- for a change in this area. If not, I would ask: How does one overload
- the comma operator while maintaining its attibutes as an operator?
-
- The problem is that ",", "&&", and "||" are not operators, they are
- "special forms" or "syntax". In an eager language without Lisp-like
- macros, there is no way to let users define constructs like this.
-
- The mistake was probably letting the user overload these constructs as
- operators in the first place. In particular, overloading "," is highly
- questionable, given the amount of work this symbol has to do in the
- language already.
-
- Thomas.
-