Binding rvalues to ref parameters redux

Nicholas Wilson iamthewilsonator at hotmail.com
Wed Mar 27 13:59:53 UTC 2019


On Wednesday, 27 March 2019 at 11:13:02 UTC, Andrei Alexandrescu 
wrote:
> 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.

Well the way it is currently worded is _very_ confusing, it could 
do with examples of whatever transformation is applied.

> 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.

It should state that.

> 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