On Sun, 03 Feb 2013 22:06:27 -0500, Andrei Alexandrescu
<[email protected]> wrote:
On 2/3/13 9:23 PM, kenji hara wrote:
2013/2/4 Andrei Alexandrescu <[email protected]
<mailto:[email protected]>>
On 2/3/13 3:16 AM, Andrei Alexandrescu wrote:
[snip]
Some more thinking got me to three simple principles that guide the
proposed property design:
http://wiki.dlang.org/DIP23#__In_a_nutshell
<http://wiki.dlang.org/DIP23#In_a_nutshell>
> 2. A @property may have EXACTLY ONE or EXACTLY TWO parameters,
counting the implicit this parameter if at all. The ONE-parameter
version is ALWAYS a getter, and the TWO-parameter version is ALWAYS a
setter. There's no variadics, defaulted parameters, and such.
Unfortunately, I can present a counterexample.
struct S {
static int value;
static @property int foo() { return value; }
static @property void foo(int n) { value = n; }
}
void main() {
int n = S.foo;
S.foo = 1;
}
Should they be disallowed, as like module level properties?
Yes. No static properties.
Hm... can't see the reason why. Static properties play no part in UFCS
(which is what makes global properties confusing). I hope it's not
because you like your new nutshell rules too much...
Then again, @properties are for syntax, easy enough to make functions
instead.
-Steve