On Thursday, 31 May 2012 at 12:29:21 UTC, Steven Schveighoffer
wrote:
On Thu, 31 May 2012 08:27:17 -0400, Sandeep Datta
<[email protected]> wrote:
If we removed the requirement for the ampersand, along with
requiring parentheses for non-property functions, code which
expected to call the function without parentheses would
silently compile, but not do what was intended.
Consider this...
float handleRequest() {
return 1.0f;
}
float x = handleRequest; //compilation error
or
auto x = handleRequest;
writefln("%f", x); //compilation error
What about:
handleRequest;
That doesn't compile now, if handleRequest is a function pointer
(or any other variable):
Error: var has no effect in expression (handleRequest)
A much bigger problem is implicit conversions to bool, which are
used everywhere:
if (handleRequest) { ... }
assert (handleRequest);
Now, they test the result of handleRequest. After the proposed
change they test the function pointer.
If this change were to happen we'd need a loooong period between
parentheses becoming mandatory for non-properties and dropping
the & operator. We're talking years here. It's totally not
worth it.
-Lars