Slice expressions - exact evaluation order, dollar
kinke via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jul 13 14:06:28 PDT 2016
On Monday, 27 June 2016 at 02:38:22 UTC, Timon Gehr wrote:
> As far as I understand, for the first expression, code gen will
> generate a reference to a temporary copy of base, and for the
> second expression, it will generate a reference to base
> directly. If lwr() or upr() then update the ptr and/or the
> length of base, those changes will be seen for the second slice
> expression, but not for the first.
Exactly. That's what I initially asked in
> Should the returned slice be based on the slicee's buffer
> before or after evaluating the bounds expressions?
So Timon prefers the pre-buffer (apparently what DMD does), GDC
does the post-buffer, and LDC buggily something inbetween (for $,
we treat base.length as lvalue, but we load base.ptr before
evaluating the bounds, hence treating base as rvalue there).
Can we agree on something, add corresponding tests and make sure
CTFE works exactly the same? %)
> The point is that the slice expression itself does or does not
> see the updates based on whether I wrap base in a lambda or not.
I don't really see a necessity for the lambda to return the same
kind (lvalue/rvalue) of value as the expression directly.
More information about the Digitalmars-d
mailing list