Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!sdd.hp.com!spool.mu.edu!sol.ctr.columbia.edu!caen!uflorida!gatech!mcnc!decwrl!infopiz!lupine!rfg From: rfg@NCD.COM (Ron Guilmette) Newsgroups: comp.lang.c++ Subject: Re: Smart pointers and Stupid people (my reactions and a new idea) Message-ID: <3704@lupine.NCD.COM> Date: 4 Feb 91 21:53:37 GMT References: <3348@lupine.NCD.COM> <1991Jan19.190403.24325@clear.com> Organization: Network Computing Devices, Inc., Mt. View, CA Lines: 38 Regarding the idea of allowing dfeclarations of class T* { ... }; In article <1991Jan19.190403.24325@clear.com> rmartin@clear.com (Bob Martin) writes: >>... however I fear that >>Bjarne will never like it. The reason? Well, it makes the language >>"mutable" (in Stroustrup's terms)... ... > > But don't the unary operator& and operator* already violate this > rule of mutability? ARM 13.4 implies that there is no return > type restriction on these operators. So by using an Y operator*(X*) > you "Change the meaning of unary * when applied to a pointer type value." You are both right an wrong. Note that those operators can only be defined for parameters which have either some class type or some reference-to-class type. Now in the case of operator*, you are dead wrong. Allowing a definition of this operator for some class type does not make the language mutable because operator* has no existing "built-in" definition for objects of a class type. Thus, by providing your own explicit definition for operator* for one of your own class types, you are not changing the meaning of any previously existing operator which was legally applicable to objects of that class type. In the case of (unary) operator& however you make a very good point. In fact it seems to me that Stroustrup has in fact violated his own principal of "non-mutability" when he allowed (unary) operator& to be defined by the user for class types. I will make it a point to raise this philosophical inconsistancy with x3j16. -- // Ron Guilmette - C++ Entomologist // Internet: rfg@ncd.com uucp: ...uunet!lupine!rfg // Motto: If it sticks, force it. If it breaks, it needed replacing anyway.