Passing dynamic arrays
spir
denis.spir at gmail.com
Mon Nov 8 12:07:39 PST 2010
On Mon, 08 Nov 2010 20:30:33 +0100
Daniel Gibson <metalcaedes at gmail.com> wrote:
> The documentation[1] says: "For dynamic array and object parameters, which are
> passed by reference, in/out/ref apply only to the reference and not the contents."
> So, by reading the documentation one would assume that dynamic arrays are passed
> by reference - *real* reference, implying that any change to the array within
> the called function will be visible outside of the function.
> The truth however is that dynamic arrays are not passed by reference and any
> changes to the length will be lost (even if the arrays data won't be copied).
Exactly. Pass (and assign) by reference mean different semantics from what D does with dyn arrays: that changes are shared.
Denis
-- -- -- -- -- -- --
vit esse estrany ☣
spir.wikidot.com
More information about the Digitalmars-d
mailing list