www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Passing by Value vs. Reference

reply "Craig Black" <cblack ara.com> writes:
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
next sibling parent "Derek Parnell" <derek psych.ward> writes:
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 01 2006
prev sibling parent Oskar Linde <oskar.lindeREM OVEgmail.com> writes:
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
May 02 2006