Paralysis of analysis
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Dec 14 11:53:39 PST 2010
On 12/14/10 1:38 PM, Simon Buerger wrote:
> I continue to belief, that containers should be value-types. In order to
> prevent useless copying you can use something like "Impl * impl" and
> reference-counting. Then you only do a copy on actual change. This is
> the way I'm currently implementing in my own container-classes.
>
> But I see the point in making them reference-types, because copying is
> so rare in real world. Though I find the expression "new Set()" most
> strange, you are definitlely right in the following: If you make them
> reference-types, they should be classes, not structs (and final, to
> prevent strange overloading).
Coming from an STL background I was also very comfortable with the
notion of value. Walter pointed to me that in the STL what you worry
about most of the time is to _undo_ the propensity of objects getting
copied at the drop of a hat. For example, think of the common n00b error
of passing containers by value.
So since we have the opportunity to decide now for eternity the right
thing, I think reference semantics works great with containers.
Andrei
More information about the Digitalmars-d
mailing list