Topic: Overloaded operator dot
Author: jbuck@janus.Berkeley.EDU (Joe Buck)
Date: 12 Apr 91 00:31:29 GMT Raw View
There seems to be some confusion among some people about just what
the "overloaded operator dot" proposal is all about. The proposal
is intended (as Jim Adcock has argued very effectively) to make C++
a more symmetrical language. The implementation and restrictions
are strictly analogous to those with operator -> described in section
13.4.6 of the ARM. For every "identity" that adding operator. would
violate, an equivalent identity is violated by the presence of overloaded
operator -> .
For those who say "dot is not an operator (Ron G.)", neither, in the sense you
mean, is ->. Ron, I seriously suggest that you read section 13.4.6 again.
To be formal about it, to obtain the new section, first replace the
title of section 13.4.6 with "Class Member Access Using Pointer Notation"
and leave all the text the same. Now make a duplicate of the entire
section with your text editor, forming section 13.4.6b. Title this
section "Class Member Access Using Reference Notation". Then change,
in the new section, "->" to "." and "pointer" to "reference". Then,
just as operator->() must return something that can be used as a pointer,
operator.() must return something that can be used as a reference (either
because it is a reference, or because operator.() is defined for it).
If you think operator.() is kludgy, you have some justification, but you
must then admit that operator->() is equally kludgy. Either both or
neither should be in the language. In many cases, a reference notation
gives easier-to-understand, easier-to-write code than a pointer notation
does. Given this, there isn't a good reason to force the user to write
"smart pointers" when "smart references" are more natural.
--
Joe Buck
jbuck@janus.berkeley.edu {uunet,ucbvax}!janus.berkeley.edu!jbuck
Author: rfg@NCD.COM (Ron Guilmette)
Date: 21 Apr 91 23:28:05 GMT Raw View
In article <41694@ucbvax.BERKELEY.EDU> jbuck@janus.Berkeley.EDU (Joe Buck) writes:
>There seems to be some confusion among some people about just what
>the "overloaded operator dot" proposal is all about. The proposal
>is intended (as Jim Adcock has argued very effectively) to make C++
>a more symmetrical language.
I agree that the language would be more symmetrical if it allowed either
*both* of -> and . to be overloaded or *neither*.
>For those who say "dot is not an operator (Ron G.)", neither, in the sense you
>mean, is ->. Ron, I seriously suggest that you read section 13.4.6 again.
I read it. Now what?
The fact that Bjarne and Jim Adcock and you all decided (incorrectly) to
call -> an operator does not have any particular influence upon me. I'll
continue to call a spade a spade no matter how many others tell me it isn't.
>If you think operator.() is kludgy, you have some justification...
Gosh! We are in agreement after all!
>...but you
>must then admit that operator->() is equally kludgy. Either both or
>neither should be in the language.
Agreed. I vote for neither.
--
// Ron ("Loose Cannon") Guilmette
// Internet: rfg@ncd.com uucp: ...uunet!lupine!rfg
// New motto: If it ain't broke, try using a bigger hammer.