Strict definition of value types and reference types
bearophile
bearophileHUGS at lycos.com
Sat Apr 13 19:51:31 PDT 2013
Nicholas Smith:
> it is said that slices are reference types. Sure, slices hold
> references to an array, but they also carry their own data,
> which gives them value semantics.
Slices are a small value, that contains in place a length and a
pointer. The pointer refers to memory allocated elsewhere. So
slices are kind of hybrids between values and references. You can
also think of them as fat references. When you program in D you
must remember this nature of sliced, otherwise your code will not
work...
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list