properties
Michel Fortin
michel.fortin at michelf.com
Tue Jul 28 08:31:03 PDT 2009
On 2009-07-28 10:16:16 -0400, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> said:
> Well I don't think so. To repeat what I wrote elsethread: foo = bar is
> rewritten into foo(bar) if and only if auto __x = foo, __x = bar works.
> This means, a setter only works if there's a corresponding getter.
> (Write-only properties be damned.)
This may lead to strange issues if both the setter and the getter don't
have the same protection attribute, or purity, or constness of
arguments.
For instance:
protected void foo(Object o);
public pure const const(Object) foo();
Here, you can assign to foo using the property syntax only from a
non-pure functions of this class or a derived classes and when the
value you're assinging is a const(Object). Elsewhere, you can only
assign using the function syntax. Anything else would break "auto __x =
foo, __x = bar".
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list