Old problem with performance
Daniel Keep
daniel.keep.lists at gmail.com
Thu Feb 12 16:01:41 PST 2009
Rainer Deyke wrote:
> Tom S wrote:
>> Rainer Deyke wrote:
>>> If T was a reference type, 'c1' and 'c2' now share state, and it's up to
>>> the programmer to write code to prevent this.
>> No, they don't. Each instance of C has its own copy of the 't' reference.
>
> That's like saying object slicing is an intentional feature. Given the
> intended semantics of 'C', it's a bug.
It's not a bug. There are differences between value types and reference
types. Just like how there are differences between atomic types and
aggregate types. Or constant types and mutable types.
If you want a distinct copy of something, then copy it.
-- Daniel
More information about the Digitalmars-d
mailing list