Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!stealth.acf.nyu.edu!brnstnd From: brnstnd@stealth.acf.nyu.edu Newsgroups: comp.lang.c Subject: Re: Dialects, C++, Overloading Message-ID: <5137:06:46:38@stealth.acf.nyu.edu> Date: 19 Feb 90 06:46:39 GMT References: <4267@quanta.eng.ohio-state.edu> Reply-To: brnstnd@stealth.acf.nyu.edu (Dan Bernstein) Distribution: usa Organization: IR Lines: 40 Rob, the issue is not user-defined operator syntax. The issue is overloading. Say a language provides a vector library with a vector addition routine. You might write ``a = b + c'' in full as ``a = b vec.+ c''. Overloading means abbreviating vec.+ and string.+ and matrix.+ and complex.+ as a single operator. We're not asking you to write a = vec.plus(b,c); we're pointing out the problems of ambiguous abbreviation. My main concern is maintainability. I hate debugging Ada---particularly someone else's Ada---because I have to learn an entirely new language just to understand each program. I have to force myself to look suspiciously at each operator and function call, asking ``what are the types?'' and ``is it overloaded?'' If I don't read Ada so painfully, I'm liable to overlook an overloaded operator, automatically assuming that (for example) a = b + c has no side effects or that bar(x) + foo(y) is the same construction that I just debugged when I saw it in the last routine. I often have a lot of trouble finding the definition of an overloaded function---my searching tools are of no help when the syntax sucks and the definition could be in any of ten libraries. But this is only a lesser evil compared to an overloaded operator insidiously taking over the innocent plus sign while the programmer looks away. > If instead we make > the much more reassuring assumption that the programmer knows about the things > he is programming, then we have a second set of conventions to deal with: > those of the subject at hand. This is the root of the problem: you have to learn a new language just to read each new program. When that new language doesn't even have the same semantics for a = b, the reader is in big trouble. In contrast, if overloaded functions and operators had to have a special syntax, they'd be an easy-to-notice, natural first spot to look for bugs. The special syntax doesn't have to be anything more than, e.g., an initial period; but it has to be there. If the language provided a standard way to expand all overloaded operators into unambiguous versions, life would be wonderful. ---Dan