digitalmars.D - Re: Ruling out arbitrary cost copy construction?
- Pillsy <pillsbury gmail.com> Nov 01 2010
Andrei Alexandrescu Wrote: [...](Why don't you post more often?)
I mostly post during lulls at work.I can't think of a case where someone just does it because they know better.
The typical case is value types of variable length: strings (the built-in offering notwithstanding), BigInt, BigFloat, STL-style containers, possibly even vectors and matrices (though that's almost always a design mistake).
Right, that's sort of what I was thinking. I certainly don't think that containers have the value-nature, and the attempt to force them into value-type shaped holes is one of the aspects of the C++ STL that I'm not so crazy about. For strings, I already think D's solution is solid, and getting BigIntegers right is something that really ought to be left up to the library. For other more exotic "value types", where immutabilty or straight copies won't cut it, I think, "Use reference counting and copy-on-write to implement value types of variable size," would make a good point 47 when you get Scott Meyers to write /Effective D/. Point 46 would of course be, "Don't make this(this) perform expensive operations." :) The important thing to my thinking is that `this(this)` gives programmers what they need to do reference counting themselves when they need it to get their value types right. Cheers, Pillsy
Nov 01 2010