Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c++ Subject: Re: Overloaded operator dot? Message-ID: <624@taumet.com> Date: 16 Mar 91 19:57:21 GMT References: <11152@jarthur.Claremont.EDU> Organization: Taumetric Corporation, San Diego Lines: 48 dfoster@jarthur.Claremont.EDU (Derek R. Foster) writes: >I have heard a few references lately to the possibility of adding to c++ >an overloadable operator dot. I have a few questions about this: >1) Is the committee seriously considering this right now, or is this just > a suggestion? If they are considering it, what are the chances of it > passing? >2) If this suggestion is actually used, what is the syntax to invoke > the normal (un-overloaded) dot operator? The ANSI C++ Committee (X3J16) met from 11-15 March, and the issue of overloading the dot operator was discussed. The working group responsible for evaluating extensions to the language presented a summary of their deliberations, and concluded that the issue requires more study. For any suggested addition or change, an important set of questions: Q1. Will any currently-legal programs be affected? Q2. What current functionality will be lost? Q3. What functionality will be added to the language which is not now conveniently available? (What problem does this solve?) Q4. Do the benefits in Q3 make up for the costs in Q1 and Q2? (This is not a formal Committee procedure, but just some things which need to be considered.) The working group said it had not reached a conclusion on Q3 in particular. If adopted, operator dot would probably be analogous to operator arrow. It would have to return a class or reference to a class on which either operator dot was defined, or which had a member corresponding to the name on the right side of the original dot. Given this, there would be no way to use the ordinary dot on a class with operator dot, just as there is no way to use the ordinary arrow on a class with an operator arrow. In particular, you would not define both operator dot and operator arrow for the same class. The result would be unmanageable. Defining either affects the normal guarantee that given class C { ... public: int m; ... } c, *pc; then (&c)->m c.m pc->m (*pc).m are all equivalent. p->m and (*p).m are equivalent. -- Steve Clamage, TauMetric Corp, steve@taumet.com