On Sunday, 6 January 2013 at 06:14:56 UTC, Ali Çehreli wrote:
On 01/05/2013 04:58 AM, js.mdnq wrote:

> S s = S(2); foo(s) <==> foo(S(2))

For those to be equivalent, there must be a scope around the first one:

{ S s = S(2); foo(s); } <==> foo(S(2))

I think that's what you've been proposing: The compiler could generate a variable on the stack to be passed to the function that takes ref.


The compiler must, not could. It have to create the variable on the stack in order to execute the constructor.

It would still have the problem of losing potential modifications to the variable, which both C++ and D try to protect the programmer from.

Ali

Reply via email to