On Monday, 22 June 2015 at 15:39:38 UTC, Andrei Alexandrescu
wrote:
On 6/22/15 3:04 AM, "Marc =?UTF-8?B?U2Now7x0eiI=?=
<schue...@gmx.net>" wrote:
Just lower it to:
{
auto tmp = 5;
fun(tmp);
}
You need to lower an expression to an expression, not a
statement. (e.g. what if fun returns a result?)
I considered this lowering for "int fun(ref int);"
fun(42)
==>>
(function int(int a) { return fun(a); })(42)
This does work, but if fun returns a ref int, I found no way to
syntactically express that lambda. This does not parse:
(function ref int(int a) { return fun(a); })(42)
Is this a bug in the grammar?
Probably. But for lowering, the resulting AST doesn't really need
to be representable in the language's syntax. I'm sure the AST
_can_ express a lambda returning by reference.
Anway, I really think we should not deviate from the normal
lifetime rules for temporaries.