On Thursday, 24 January 2013 at 18:38:00 UTC, Adam D. Ruppe wrote:
Thinking about it, this isn't quite a full circle. It does
improve a bit.
If we aren't going dip21, how about:
===
Everything stays the way it is now, except:
* if a @property is called with parens, they always apply to
the return value
* -property hopefully dies.
===
If this means keeping the writeln = ""; then vote++. I've got no
issues
with the property syntax for methods. I actually want them. Why
should properties only get the shorter syntax?
I don't really like it, it leaves a number of problems
behind... but that would be an improvement on the status quo. I
don't hate it.
So:
alias void delegate() Callable;
Callable nonprop();
@property Callable prop();
Callable returned = nonprop; // ok, the parens are optional
Callable returned = nonprop(); // ok, nonprop() just calls
nonprop like any other function
Callable returned = prop; // ok, no parens still calls, just
like before
Callable returned = prop(); // NOT GOOD: the () applies to the
Callable (which returns void), not prop, because prop has
@property
BTW
nonprop()(); // calls the Callable (this expression returns
void)
prop()(); // nonsense (prop() returns void, which is not
callable)
---
int nonprop();
@property int prop();
int returned = nonprop; // fine, optional parens
int returned = nonprop(); // fine
int returned = prop; // fine, we just call prop
int returned = prop(); // NO GOOD: the () always applies to the
return value, which in this case is int, which is not callable