Binding rvalues to ref parameters redux
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Wed Mar 27 11:13:02 UTC 2019
On 3/27/19 12:33 AM, Nicholas Wilson wrote:
> It would be far better to describe this through lambda lowering.
One important realization working on this was that insertion of
constructors and destructors cannot be realized via lambda lowering
because lifetimes don't follow some natural scoping. For example, the
temporaries created on the left-hand side of && survive through the end
of the full expression, whereas those created on the right-hand side do
not. The "?:" operator is a hot mess including additional hidden state
variables, conditional destruction thus breaking the language rules etc.
I'll make sure the document mentions why lowering is not the appropriate
mechanism to describe insertion of constructors and destructors.
One other thing is that these temporary construction and destruction
rules preexisted. In fact probably the nicest thing about the DIP is
that no new rules are introduced - temporaries are created and destroyed
exactly as if there was no "ref" for the parameter. That way we could
migrate some of the DIP into the spec, thus simplifying the DIP. I've
already done that with the definitions of "full expression", "lvalue",
and "rvalue".
More information about the Digitalmars-d
mailing list