On Friday, 23 March 2018 at 22:01:44 UTC, Manu wrote:
Can you please explain these 'weirdities'?
What are said "major unintended consequences"?
Explain how the situation if implemented would be any different
than
the workaround?
This seems even simpler than the pow thing to me.
Rewrite:
func(f());
as:
{ auto __t0 = f(); func(__t0); }
How is that worse than the code you have to write:
T temp = f();
T zero = 0;
func(temp, zero);
I feel like this example wasn't really concrete enough for me. I
wrote a version below that I think made it a little clearer for
myself.
-----
import std.stdio : writeln;
struct Foo
{
int data;
}
int foo(Foo x)
{
writeln("here");
return x.data;
}
int foo(ref Foo x)
{
writeln("there");
return x.data;
}
void main()
{
auto x = Foo(5);
auto y = foo(x);
writeln(y);
auto z = foo(Foo(5));
writeln(z);
}