On Monday, 4 February 2013 at 02:36:41 UTC, Timon Gehr wrote:
On 02/04/2013 03:23 AM, kenji hara wrote:
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?

Kenji Hara

Probably. (static essentially means module-level, but in a potentially nested name space.)

I disagree. Static properties can be allowed because they're not ambiguous. The problem with module-level:
@property void foo(int n) {}
...are the two interpretations of foo as either a setter taking an int or a getter property of int type. So, one of those interpretations must be disallowed. But, with static member properties, there aren't multiple interpretations.

Reply via email to