Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!chinet!nucsrl!gore From: gore@nucsrl.UUCP (Jacob Gore) Newsgroups: comp.lang.c++ Subject: Re: Operator overloading considered harmful Message-ID: <8180001@nucsrl.UUCP> Date: 10 Jan 88 21:28:21 GMT References: <240@vsi1.UUCP> Organization: Northwestern U, Evanston IL, USA Lines: 36 / nucsrl:comp.lang.c++ / steve@vsi1.UUCP (Steve Maurer) / Jan 8, 1988 / > I have a bone to pick with operator overloading. [...] >Consider the following: > > foo(int i) > { > i #= i ^^ i @& i; > } > >what does it do?? [...] It was my impression that in C++ you could not define operators with new names -- only overload existing names. (The overloaded operators keep the associativity and precedence qualities of the built-in operators of the same name, right?) But anyway, no language can prevent a determined nut from writing programs with confusing semantics. What should we "consider harmful" next, alphanumeric variable names? Consider the following: nonobservance(int depressant) { hoke = unhampered + serf / chiaroscuro; } What does IT do? If a programmer does wants to write clear programs, then a better language will support that goal, while a worse language will get in the way. Names of operators should be picked in such a way that they make sense for the context in which they are used. This is harder to do when you cannot define your own operators, and harder yet to do when you cannot even overload predefined operator names. Jacob Gore gore@EECS.NWU.Edu Northwestern Univ., EECS Dept. {gargoyle,ihnp4,chinet}!nucsrl!gore