Slice expressions - exact evaluation order, dollar
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jul 18 18:11:18 PDT 2016
On 12.07.2016 23:56, Iain Buclaw via Digitalmars-d wrote:
>> >
>> >What is the justification why the base should be evaluated as an lvalue?
>> >
> Because changes made to a temporary get lost as they never bind back
> to the original reference.
> ...
Which I'd expect. It is just like:
int x = 0;
assert(3 == ++x + ++x);
If the first '++x' was evaluated by reference, this would be 4, not 3.
> Regardless, creating a temporary of a struct with a cpctor violates
> the semantics of the type - it's the job of the frontend to generate
> all the code for lifetime management for us.
> ...
Yes, but the front end can also be wrong. What is unclear here is if/why
the front end should evaluate the array base by reference.
> (Sorry for the belated response, I have been distracted).
(Me too.)
More information about the Digitalmars-d
mailing list