Property discussion wrap-up
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sun Jan 27 20:40:35 PST 2013
On 1/27/13 9:16 PM, deadalnix wrote:
> 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.
To get the address of a function's result: &fun().
> Secondly,
> it create a different behavior for variables and source code defined
> functions.
I'm not convinced that's a bad thing. I've come to realize functions and
variables _are_ different.
> This is one of those cases where the omition of () cascade in more mess.
I disagree.
> At the end, ask any dev and he/she will say you that foo is a function.
> Why not make foo a function ?
The pros and cons have been hashed many times, I'm not sure I have much
to add.
Andrei
More information about the Digitalmars-d
mailing list