Suppose I have: import std.range; auto a=iota(complex_expr_returning_3());
I'd like to have a function/trait/template/compiler magic that takes variable a and generates a string that can be mixed in to represent the type of a. The difficulty is that typeid(a).to!string doesn't work for Voldermort types: typeid(a).to!string produces "std.range.iota!(int, int).iota.Result", which is not very useful as it can't be mixed in a program, being a voldemort type, eg: mixin("std.range.iota!(int, int).iota.Result a;"); //compile error However, the compiler could help reduce it to something as simple as possible, eg: "typeof(iota(int.init))" here this would work: mixin("typeof(iota(int.init)) a;"); //works Is it possible to do that in a generic way, such that it hides as much as possible the details of the expression (here, "complex_expr_returning_3()" should be simplified to int.init) Or is there another trick I could use to instantiate a variable with same type as a? NOTE: typeof(a) a2; works even though http://www.drdobbs.com/cpp/voldemort-types-in-d/232901591?pgno=2 says it won't work, "Sorry, that won't work, the compiler will not allow a Voldemort Type to be instantiated outside of its scope " (although that's doesn't help with my original problem)