Efficiently passing structs
Baz via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun May 3 20:29:59 PDT 2015
On Monday, 4 May 2015 at 01:58:12 UTC, bitwise wrote:
> The documentation doesn't say anything about "in" being a
> reference, but it doesn't say that "out" parameters are
> references either, even though it's usage in the example
> clearly shows that it is.
>
> Thanks,
> Bit
>
> http://dlang.org/function.html#parameters
it's specified in http://dlang.org/abi.html (at the bottom):
"out and ref are passed as pointers".
The logic seems to be that if it's not specified then it's copied.
Maybe `const ref` is what you're looking for...passed as pointer
but the compiler will prevent writing the parameter, though it's
still possible to take the address and to modify the param if the
function is not @safe.
More information about the Digitalmars-d-learn
mailing list