On 27/12/11 3:10 PM, Andrei Alexandrescu wrote:
On 12/27/11 4:32 AM, Peter Alexander wrote:
On 27/12/11 3:05 AM, Andrei Alexandrescu wrote:
On 12/26/11 8:23 PM, Peter Alexander wrote:
I am
not convinced that it can be used seamlessly without some relatively
large changes to the language.

I repeat that opDispatch and auto ref were invented for this, so
anything that doesn't work now is a bug. There are no changes needed to
the language, only fix the bugs :o).

How do you call template member functions of the held object without
changing opDispatch?

The idea is to pass the entire template instantiation as the string.

obj.foo!(bar, baz)(a, b);

->

obj.opDispatch!("foo!(bar, baz)")(a, b);



Andrei

I don't believe this will work in general when the template parameter passed in requires name look-up in the local scope.


struct Foo
{
    int bar(alias f)() { return f(); }
}

void main()
{
    static int fun() { return 1; }

    RefCounted!Foo foo;
    writeln(foo.bar!fun()); // "fun" isn't in scope when mixed in.
}

Reply via email to