On 27/12/11 1:29 AM, Andrei Alexandrescu wrote:
We can easily have opDispatch look at field names. But I think it's poor
design to expose bald data anyway.
I disagree, especially with immutable structs. There's no point wrapping
immutable data in functions or properties.
Also, what about template member functions of the held object?
struct Foo
{
int get(int X)() { return X; }
}
void main()
{
RefCounted!Foo f;
writeln(f.get!123()); // Doesn't work either
}
This is a problem.
I would recommend postponing any major additions to Phobos that use
opDispatch to forward calls until it has been investigated in full. I am
not convinced that it can be used seamlessly without some relatively
large changes to the language.
Another potential problem of the top of my head: what about operator
overloads on the held object? Just forward from opUnary/opBinary etc.?
What about held objects that overload opAssign?
What if the held object is itself a RefCounted?