Thread overview | |||||
---|---|---|---|---|---|
|
May 01, 2006 Passing by Value vs. Reference | ||||
---|---|---|---|---|
| ||||
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 Re: Passing by Value vs. Reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to Craig Black | 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 Re: Passing by Value vs. Reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to Craig Black | 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
|
Copyright © 1999-2021 by the D Language Foundation