Thread overview
Passing by Value vs. Reference
May 01, 2006
Craig Black
May 01, 2006
Derek Parnell
May 02, 2006
Oskar Linde
May 01, 2006
Are structs in D passed by reference by default?  I know if I specify "out" or "inout" they would have to be, but what about just regular parameters without qualification?

-Craig


May 01, 2006
On Tue, 02 May 2006 01:54:54 +1000, Craig Black <cblack@ara.com> wrote:

> Are structs in D passed by reference by default?  I know if I specify "out"
> or "inout" they would have to be, but what about just regular parameters
> without qualification?
>

As far as I can see when using the "in" type of argument, structs are copied to the stack before calling the function and popped off when the function returns.

-- 
Derek Parnell
Melbourne, Australia
May 02, 2006
Craig Black skrev:
> Are structs in D passed by reference by default?  I know if I specify "out" or "inout" they would have to be, but what about just regular parameters without qualification?

Regular parameters without qualifiers are "in" by default. Structs as in-parameters are always passed by value. (Internally, there may be a pointer to a stack allocated copy involved depending on the local platform ABI, but that does not change the semantics.)


/Oskar