On 02/27/2013 11:57 AM, deadalnix wrote:
On Wednesday, 27 February 2013 at 10:38:05 UTC, Timon Gehr wrote:
I considered optional parentheses where you would have an error, but I'm
afraid that this could create weird effect with function overloads.


There are no weird effects with function overloads in what I propose.
What is the issue you are seeing?


Consider the following situation :

void foo(uint a) {
     writeln("a is ", a);
}

uint bar() {
     return 0;
}

foo(bar); // a is 0


error: incompatible argument types (uint function()) to function foo(uint a)

Later, this function is added :
void foo(uint function() a) {
     writeln("function not executed");
}

The statement above become :
foo(bar); // function not executed

Note that foo can be in other modules, so it may not be obvious. It can
be solved in various ways, and I actually implemented some to play
around. I was not satisfied with the result.


I see. This problem does not occur. (There is no UFCS in the above code.)

It may be limited to the case where expression can't be used as
statement because it has no effect.

Then it is not worth it.

It would kick in with the example you gave.

Not necessarily, it would depend on the context of the expression I gave.

Reply via email to