UFCS & overloaded property getters/setters
Kapps via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jun 13 11:40:27 PDT 2014
Odd, I thought you weren't able to override only a single
overload of a property? I might be imagining things, but I recall
at least previously that you had to override all getters/setters
if you wanted to override any for a property.
Personally I think D made a significant mistake in the way
properties are handled, with treating them as multiple methods
tenuously tied together with sticking @property on (hopefully)
all of them. I'd much rather it were a single property with
getters/setters inside, similar to the way C# does it. Ideally
something like:
/// Documentation
@property int foo() @safe pure nothrow {
get() const { return _bar.foo; }
set(int val) { _bar.foo = val; }
}
As opposed to
/// Documentation
@property int foo() const @safe pure nothrow {
return _bar.foo;
}
/// ditto
@property void foo(int val) @safe pure nothrow {
_bar.foo = val;
}
Then you would actually have to override all or nothing, it would
be treated as a single property not as multiple method overloads,
etc.
More information about the Digitalmars-d
mailing list