June 15, 2008
Reply to Bruno,

> module test;
> class A
> {
> void Template_foo(int i) {writef("Hello %d\n", i);}
> void Template_bob(int i) {writef("See ya %d\n", i);}
> template Template(string s: "foo") { alias Template_foo Template; }
> template Template(string s: "bob") { alias Template_bob Template; }
> }
> class B : A
> {
> override void Template_foo(int i) {for(int j=0;j<i;j++)
> writef("Hello\n");}
> override void Template_bob(int i) {for(int j=0;j<i;j++) writef("See
> ya\n");}
> }

I think that might work in some cases (maybe even mine). However In my cases the called functions are generated so once I need to generate different names for the functions I might as well go with mixins for the calls and then there is no point in using templates. But even if it can be made to work it seems so klugey...

Walter: How restrictive would the rules have to be before templates functions could be virtual? For my case I could tag them with an extra attribute, make sure there are no non virtual ones and a lot of other things. 


1 2 3
Next ›   Last »