Adam D. Ruppe wrote:
import std.variant;
struct Extendable {
Variant[string] properties;
Variant opDispatch(string name)() {
return properties[name];
}
Variant opDispatch(string name, T)(T t) {
properties[name] = t;
return properties[name];
}
}
void main() {
auto a = Extendable();
a.sweet = 10;
a.cool = { a.sweet = a.sweet + 1; } // could probably fix
++ too..
// fails with std.variant but the language *could* do it
a.cool(); // exercise for the reader: maek this work! Gotta
add opCall.
}
Alright I give up dammit! How do you use opCall() to make
a.cool() work?