Property discussion wrap-up

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Jan 27 16:07:05 PST 2013


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.

BTW also regarding optional parentheses, while I was working on 
https://github.com/D-Programming-Language/tools/pull/41/files I 
refactored a bit of code to use UFCS and paren-less syntax. I must say I 
find this a very fluid style of programming that I'd hate to lose.

One more thought - though optional parens and properties are distinct 
issues, there is some interaction: optional parens reduce the need for 
@property annotation on read-only properties.


Andrei


More information about the Digitalmars-d mailing list