@property - take it behind the woodshed and shoot it?
Adam D. Ruppe
destructionator at gmail.com
Thu Jan 24 10:37:59 PST 2013
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.
===
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
More information about the Digitalmars-d
mailing list