Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!att!cbnewsl!bdsz From: bdsz@cbnewsl.att.com (bruce.d.szablak) Newsgroups: comp.lang.c++ Subject: Re: Assignments to reference variables [ and operator.() ] Summary: why not? Message-ID: <1990Sep24.173631.22951@cbnewsl.att.com> Date: 24 Sep 90 17:36:31 GMT References: <8445@jarthur.Claremont.EDU> <57570@microsoft.UUCP> <1677@lupine.NCD.COM> Distribution: usa Organization: AT&T Bell Laboratories Lines: 31 In article <1677@lupine.NCD.COM>, rfg@NCD.COM (Ron Guilmette) writes: > I can't understand why Bjarne and Jim and others have so much difficulty > seeing the fundamental irrationality of allowing operator overloading > to be done to things which are clearly not operators. Operator overloading is just syntatic sugaring to permit succinct and readable expression of the programmer's intent. Being able to overload the "->" construct works well with C++s user type system. I used it to implement a reference counting pointer type for example, and the code written using that type was much more readable as a result. That is a justification for permitting it to be overloaded. > If they really think that this is such a swell idea, then I challenge them > to tell me (and everyone) why they are not suggesting allowing `operator{' > to be overloaded. Off hand, I can't think of a user defined type that using '{' construct would result in more readable programs, but since it is used in the definition of initialized data I wouldn't discount that there is one... > If there are any rules for what should be called an operator and what should > not, and what should be overloadable and what should not, I'd like to see > them! If these rules are at all consistant, if they make any sense > whatsoever, and if they still would seem to permit -> to be overloaded, > I'll eat my hat. Prolog permits any legal identifier to be defined as an operator with a precedence and associativity. Other languages choose to do things in other ways. In the end, the "rules" are found in the manual. Perhaps "operator" is an unfortunate choice of terminology, but were stuck with it.