www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Assigning parameter on entry to a function and assigning back on exit

reply Victor Porton <porton.victor gmail.com> writes:
Somewhere in my brain memory, it was written:

A function argument that is both input and output, may be passed 
to the function either as reference or do two assignments: on 
entry of the function it is assigned to the parameter, on exit it 
is assigned back. Whether it is a reference or two assignments 
depends on the reference semantics of the type.

Now I can't find this in the reference manual. Please help to 
refresh/correct my memory.
Nov 25 2022
parent reply Victor Porton <porton.victor gmail.com> writes:
On Friday, 25 November 2022 at 11:01:09 UTC, Victor Porton wrote:
 Somewhere in my brain memory, it was written:

 A function argument that is both input and output, may be 
 passed to the function either as reference or do two 
 assignments: on entry of the function it is assigned to the 
 parameter, on exit it is assigned back. Whether it is a 
 reference or two assignments depends on the reference semantics 
 of the type.

 Now I can't find this in the reference manual. Please help to 
 refresh/correct my memory.
Probably, in my memory this was stored regarding Ada and misattributed to D, wasn't it? Does D have or no this kind of feature?
Nov 25 2022
parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 11/25/22 05:06, Victor Porton wrote:

 A function argument that is both input and output, may be passed to
 the function either as reference or do two assignments: on entry of
 the function it is assigned to the parameter, on exit it is assigned
 back.
The way I understand it with C, C++, and D, if there were such an assignment back, that could only be performed by the caller. I don't think the ABIs of those languages support that behavior. I think there is only pass by reference for out parameters. Ali
Nov 25 2022