Using templates to switch interface implementation class

Tom S h3r3tic at remove.mat.uni.torun.pl
Tue May 23 06:35:32 PDT 2006


Marcin Kuszczak wrote:
> But if anyone have idea how to make it completely using static templates to
> achieve same effect it would be interesting for me. Especially I wonder why
> my code doesn't work as expected (It works for one binging, but not for
> more):
> (...)

There are a few problems with templates and mixins. I've posted about 
them to digitalmars.D, we'll see if something can be done about them...


> 1) Why there must be alias in line 2? without this "alias" in line 5
> compiler can not see T from line 1.

Not sure, it might be a bug, but it may be related to one sentence from 
the spec: "Unlike a template instantiation, a template mixin's body is 
evaluated within the scope where the mixin appears, not where the 
template declaration is defined".


> 2) Do I understand it correctly that above code should instantiate to e.g.:
>         template getInstance(MI:IMainView) {
>                 MI getInstance() {
>                 return new MainViewTest;
>                 }
>         }
> as it is not possible to put anything instead of 'MI' when instantiating?

Sorry, but I don't understand what you're asking about...


> PS. It's good to have helpful hand in D here in Poland. Kraków sends
> greetings to Toruń :-)

I'm always there to help fellow D coders ;) Greetings from Torun !


-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d-pu s+: a-->----- C+++$>++++ UL P+ L+ E--- W++ N++ o? K? w++ !O 
!M V? PS- PE- Y PGP t 5 X? R tv-- b DI- D+ G e>+++ h>++ !r !y
------END GEEK CODE BLOCK------

Tomasz Stachowiak  /+ a.k.a. h3r3tic +/



More information about the Digitalmars-d-learn mailing list