Path: utzoo!censor!geac!torsqnt!hybrid!scifi!bywater!uunet!microsoft!jimad From: jimad@microsoft.UUCP (Jim ADCOCK) Newsgroups: comp.lang.c++ Subject: Re: Overloaded operator dot? Message-ID: <71650@microsoft.UUCP> Date: 2 Apr 91 20:52:44 GMT References: <11152@jarthur.Claremont.EDU> <624@taumet.com> <12193@pasteur.Berkeley.EDU> <4610@lupine.NCD.COM> Reply-To: jimad@microsoft.UUCP (Jim ADCOCK) Organization: Microsoft Corp., Redmond WA Lines: 67 In article <4610@lupine.NCD.COM> rfg@NCD.COM (Ron Guilmette) writes: |Horse pucky! Prove it! What would such a "proof" consist of Ron? I'd post an example using references, you'd post an example using pointers, you'd claim your code is "better" and I'd claim my code is "better." Lets be honest, some people think C++ shouldn't have had references in the first place, but are still fighting a read guard to cripple them now that they're in the C++ language. |I claim that even if you *had* your so-called "smart references" today, |there is absolutely nothing that you could do with them that you could |not do just as well using only "smart pointers". One counter-example to this claim already posted is the example of a ref-counted element of a matrix. Matrix::operator[] needs to return a "smart reference" class because it needs to do reference counting, and it needs to follow value semantics because it in turn needs to have operator[] applied to it in order to get to the individual element. |I also claim that there is nothing that you could do significantly *easier* |with "smart references" than you could with just smart pointers. Show me how you do the reference counted element of a matrix example? Also, I claim "smart pointers" today are frequently used in situations where the "smart pointer" class does not support the full contigency of pointer operations -- but rather can only be used to refer to a single object. Such is not properly a pointer -- it doesn't support pointer operations such as increment, decrement, operator[], etc. If its a "reference counting smart pointer" chances are it doesn't even support assignment of null -- because reference counting smart pointers need to target an actual objec that keeps track of the reference count. So, much of the time "smart pointers" are actually implementing "smart references" today -- but are using inappropriate syntax. Since these people are actually implementing references, why can't they use reference syntax???? |If you have a counterexample I encourage you to post it and prove me wrong. |(Post the code please. Hemming and hawing in flowery prose will not help |to make the point either way.) Again, people have already posted examples of returning an instance of some class from a matrix via operator[]. Such class is naturally a "smart reference" since it in turn needs to follow "value semantics" in order that operator[] can in turn be applied to it. Show me how you solve this problem using "smart pointers" ??? Also, Ron is using a a circular argument. While doing his best to keep people from having compilers that support operator-dot, Ron complains that people don't have good examples of using operator-dot. We haven't exactly had a flood of good examples of using templates or exceptions posted to notes either -- because most people don't have compilers supporting such yet. How about if Ron posts his favorite "smart pointer" code, I'll do my best to convert it to "smart reference" code, and then we'll argue about which is inferior? Again, why are some people so vested in maintaining a minute non-orthogonal wart in the language??? Why not just make the language orthogonal, and say "all operators can be overloaded"??? If some C++ programmers consider overloading operator-dot a "bad" idea -- **** THEN DONT DO IT! **** Why is it necessary to force your prejudices of what constitutes "good programming" onto others?