Template mixins at compile-time

Uriel uriel at inbox.ru
Mon Oct 27 07:25:47 PDT 2008


I've been experimented with D's template system and noticed some strange thing.
Here is the sample code.

template Foo(string className)
{
  class Bar
  {
  }

  mixin("alias Bar " ~ className ~ ";");
}

After that I have new class with the given name and everyting is ok. But I can't create it with Object.factory() method.
In fact, I can call typeid() for this class and recieve correct information about it. `Foo!("bla").Bar` for example. I've examined source code of the Object.factory() and found out that ModuleInfo doesn't contain information about created class.
I don't know much about how this information is generated at compile-time but suppose that it should be generated after mixins will be evaluted.
Could anybody clear it up?



More information about the Digitalmars-d mailing list