home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13550 < prev    next >
Encoding:
Internet Message Format  |  1992-09-11  |  2.2 KB

  1. Path: sparky!uunet!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!tmb
  2. From: tmb@arolla.idiap.ch (Thomas M. Breuel)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Answers on a postcard...
  5. Message-ID: <TMB.92Sep11212846@arolla.idiap.ch>
  6. Date: 12 Sep 92 01:28:46 GMT
  7. References: <92254.104002KKEYTE@ESOC.BITNET> <1992Sep10.174914.838@taumet.com>
  8.     <92255.112151KKEYTE@ESOC.BITNET>
  9. Sender: news@ai.mit.edu
  10. Reply-To: tmb@idiap.ch
  11. Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
  12.     Perceptive)
  13. Lines: 32
  14. In-reply-to: KKEYTE@ESOC.BITNET's message of 11 Sep 92 18:52:30 GMT
  15.  
  16. In article <92255.112151KKEYTE@ESOC.BITNET> KKEYTE@ESOC.BITNET (Karl Keyte) writes:
  17.  
  18.    >In the expression in parens, it is unspecified whether "x=1" or
  19.    >"x+1" is evaluated first.  They are arguments to the "operator,()"
  20.    >function, not the left and right side of a comma-expression.  If
  21.    >"x+1" is evaluated first, which is legal, it will use an
  22.    >uninitialized "x.value".
  23.    >
  24.    >Don't write code which depends on unspecified order of evaluation.
  25.  
  26.    The implication of what you say is that it is not possible to overload
  27.    operators maintaining the correct functionality of the operator.  This
  28.    indeed means that precedence in overloaded operators cannot be maintained
  29.    if all operands are simply passed as arguments to the function implementing
  30.    the operator functionality and evaluated in a language independent order.
  31.    Imagine commonly used "chain" operators such as && and ::.
  32.  
  33.    If what is described above is correct, and Mr.Clamage clearly has much
  34.    experience in the area, then I think we have justification for pressing
  35.    for a change in this area.  If not, I would ask: How does one overload
  36.    the comma operator while maintaining its attibutes as an operator?
  37.  
  38. The problem is that ",", "&&", and "||" are not operators, they are
  39. "special forms" or "syntax". In an eager language without Lisp-like
  40. macros, there is no way to let users define constructs like this.
  41.  
  42. The mistake was probably letting the user overload these constructs as
  43. operators in the first place. In particular, overloading "," is highly
  44. questionable, given the amount of work this symbol has to do in the
  45. language already.
  46.  
  47.                     Thomas.
  48.