Get template and its instantiation parameters

Jarrett Billingsley jarrett.billingsley at
Wed Oct 7 10:15:46 PDT 2009

On Wed, Oct 7, 2009 at 12:54 PM, BCS <none at> wrote:
> Hello Michal,
>> If one has a template instance, is it possible to get template name
>> and parameter type that was used for instantiating, at compile time?
>> consider:
>> class List (T) {}
>> List!(int) lst;
>> Foo (lst);
>> I want to create such template Foo which prints:
>> List!(int)
>> List
>> int
> You could try parsing T.stringof at compiletime to extract the parts you
> need.

This is *exactly* the kind of bullshit that I hate about string
mixins. The thought process just ends up going "oh, why bother having
any terse, elegant mechanisms to get at program information when you
can *parse arbitrary code at compile time*? And why do you need macros
when a string substitution will do?" Is it powerful? Sure. But it's
lame, ugly, slow, easy to mess up, lacks hygiene, and is unidiomatic.
String mixins are basically just a text preprocessor with user-defined
functionality. Neat, but it can only get you so far before you're in
tarpit territory.

More information about the Digitalmars-d-learn mailing list