Possible @property compromise
TommiT
tommitissari at hotmail.com
Fri Feb 1 23:09:59 PST 2013
On Saturday, 2 February 2013 at 03:50:49 UTC, Zach the Mystic
wrote:
> [..]
Then, if we used your proposed nested structs to implement
properties, pretty weird things like this would become possible:
struct A
{
int _value;
struct B
{
int get() { return _value; }
alias this = get;
void opAssign(int v) { _value = v; }
}
B length;
}
void func(T)(ref A a, T oldLength)
{
a.length = 100;
// Trying to restore 'a' back to the old length:
a.length = oldLength;
}
void main()
{
A a;
a.length = 5;
func(a, a.length);
assert(a.length == 100);
}
More information about the Digitalmars-d
mailing list