DIP23 draft: Fixing properties redux

FG home at fgda.pl
Sun Feb 3 05:16:08 PST 2013


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; }
     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.


More information about the Digitalmars-d mailing list