ref?

Rainer Deyke rainerd at eldwood.com
Sun Feb 15 10:51:37 PST 2009


Andrei Alexandrescu wrote:
> Well I never seemed to have a problem with it, quite the contrary in
> fact. Values are easier to reason about because they don't have aliasing
> and don't foster long-distance interdependencies.

This.

When the container is used in a struct, then it must not only be copied,
but deep-copied when the outer struct is copied.  The same applies when
the container is used in a class that has a cloning operation defined.

When the container is used in a class that cannot be cloned or is
directly placed on the stack, then it doesn't really matter if the
container has reference or value semantics, since the variable that
holds the container isn't being copied anyway.

For those very rare cases where you /want/ the container to be shared,
you can always use a pointer to the container.


-- 
Rainer Deyke - rainerd at eldwood.com



More information about the Digitalmars-d mailing list