
On 7/10/04 12:32 PM, "Andrei Alexandrescu (See Website for Email)" <andrewalex@hotmail.com> wrote:
For the record, I've decided to eliminate that coding standard
on overloading operator,()
for now. The sheer facts that (1) a useful library overloading operator,() is in boost, and (2) reasonable people can disagree about said overloading being good or bad, convinced me.
I'm disappointed in this. While there may be identifiable exception cases, I think in general overloading operator,() is problematic. I think the initialization library's use of the comma operator in this way is like the streams use of >> and <<. These are really new operators which happen to be spelled the same way as old operators. When we see "std::cout << ...", we don't think, "Oh, this is bit shift which in the case of streams means..." No we think "Oh, this is the insertion operator..." I think of the comma operator as the sequence operator and as such it cannot be properly overloaded. To overload operator,() in the way that the initialization library does is to introduce a new operator in much the same way that the stream class did with << and >>. Perhaps the coding guideline should be "overload operator,() only when you wish to create a new semantic meaning for the comma operator (other than sequence) and see the coding guideline that says to avoid creating new semantic meanings for operators." -- Jon Kalb