On Monday, 28 January 2013 at 00:07:05 UTC, Andrei Alexandrescu wrote:
On 1/27/13 3:22 PM, Zach the Mystic wrote:
Several suggestions here:

With regard to optional parentheses, it had been suggested that any
ambiguity be regarded as an error. This is the example I used:

int foo() { return 4; }
auto x = foo; // Error: gives 4 or gives function foo?

I suggested the ambiguity be resolved thus:

auto x = foo(); // parens to get the return value
auto y = cast(function) foo; // cast(function) gives the function

I was thinking of just using &foo, like in C.


The &foo syntax is really not a good one.

First, it is ambiguous with function that return a reference. Secondly, it create a different behavior for variables and source code defined functions.

This is one of those cases where the omition of () cascade in more mess.

At the end, ask any dev and he/she will say you that foo is a function. Why not make foo a function ?

Reply via email to