Other

digitalmars.D - properties question

should this work? following the spec:
A property is read by calling a method with no arguments; a property
is written by calling a method with its argument being the value it
is set to.
1 cent question: are the overloaded opCall methods of the struct test
considered as separated methods?
Apparantly only the read opCall is taken into account.
bye,
roel
ps: only thing against it I found was that one can't add non-static
functions to classes, but the fact that it would work for reads and not
for writes is somehow inconsistent
Example:
-------------------------------------------------------------------
struct test(T)
{
T value;
T opCall(T value_) { return value = value_; }
T opCall() { return value; }
}
class A
{
test!(int) p;
}
void main()
{
A a = new A();
// it won't use "property!(int).opCall(int value_)"
// a.p = 49; // error: cannot implicitly convert int to test
// a.p(51); //does work
a.p.value = 50;
// but here it uses "property!(int).opCall()"
printf("%d\n",a.p);
}