2013/2/3 FG <[email protected]> > 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. >
Two arguments @property function would be declared only in module level, and just be called with UFCS. I think that functions annotated with @property must not have default parameters. As you show, it would introduce not little ambiguity. Kenji Hara
