On 2/3/13 8:16 AM, FG wrote:
On 2013-02-03 09:16, Andrei Alexandrescu wrote:
Walter and I have had a discussion on how to finalize properties.

Very reasonable in the majority of the proposal.
I can't, however, get my head around 2-arg property functions:

int a_;
@property void a(int v, bool rev=false) { a_ = rev ? -v : v; }

I'd say never allow defaulted arguments with @property.

a = 10; // fine
10.a = true; // this feels backwards, true is just an extra flag

The boolean flag is optional and making it the rhs of the assignment
suggests it is the value which will be set. On the other hand switching
argument positions, resulting in true.a = 10 also feels very strange.

I'd say: allow only 0 or 1 argument in properties.
If you need more arguments, write a normal function for it.

Two-argument @properties are always setters.


Andrei

Reply via email to