DIP23 draft: Fixing properties redux
kenji hara
k.hara.pg at gmail.com
Sun Feb 3 18:23:02 PST 2013
2013/2/4 Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org>
> 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?
Kenji Hara
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130204/e015185f/attachment.html>
More information about the Digitalmars-d
mailing list