digitalmars.D - Passing by Value vs. Reference
- Craig Black (4/4) May 01 2006 Are structs in D passed by reference by default? I know if I specify "o...
- Derek Parnell (7/11) May 01 2006 As far as I can see when using the "in" type of argument, structs are
- Oskar Linde (6/9) May 02 2006 Regular parameters without qualifiers are "in" by default. Structs as
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 01 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
May 02 2006