Properties sugestion.
Jb
jb at nowhere.com
Mon Aug 20 12:55:36 PDT 2007
class Foo
{
int _foo;
property Bar
{
void opAssign(int i) { _foo = i;}
int opRValue() { return _foo; }
int OpPostInc() { _foo++; return _foo-1; }
}
property Baz { void opRValue() { return _foo*2; } }
}
I'll admit i didnt follow all of the points in the original thread but it
got me thinking that why not re-use operator overloading syntax to define
the operators that can (or cant) be used with a property. Perhaps require
that the correct one be implemented when the property is used as an lvalue?
Just those problematic operators that cause ambiguity could just cause a
compiler error if used when not implemented.
If you want to get a delegate to the function you could simply address the
operator function...
&Foo.Width.opAssign;
More information about the Digitalmars-d
mailing list