Re: Templates at runtime

2009-02-15 Thread Simen Kjaeraas
On Fri, 13 Feb 2009 03:51:01 +0100, Justin wrote: I'm trying to instantiate a templated class at runtime and having some trouble. My thought is that since something like "Collection!(int)" will return a valid classinfo, I ought to be able to use ClassInfo.find() and then .create: module

Re: Templates at runtime

2009-02-14 Thread Christopher Wright
Ary Borenszweig wrote: Christopher Wright wrote: Justin wrote: Is there a way to "find" a classinfo for such a class at runtime? The slow way: foreach (modul; ModuleInfo) foreach (info; modul.localClasses) if (info.name == name) return info; return null; It doesn't work. It see

Re: Templates at runtime

2009-02-13 Thread Steven Schveighoffer
"Christopher Wright" wrote > Justin wrote: >> Is there a way to "find" a classinfo for such a class at runtime? > > The slow way: > > foreach (modul; ModuleInfo) > foreach (info; modul.localClasses) > if (info.name == name) return info; > return null; If you look at the source for ClassInfo.find,

Re: Templates at runtime

2009-02-13 Thread Ary Borenszweig
Christopher Wright wrote: Justin wrote: Is there a way to "find" a classinfo for such a class at runtime? The slow way: foreach (modul; ModuleInfo) foreach (info; modul.localClasses) if (info.name == name) return info; return null; It doesn't work. It seems only top level classe

Re: Templates at runtime

2009-02-13 Thread Christopher Wright
Justin wrote: Is there a way to "find" a classinfo for such a class at runtime? The slow way: foreach (modul; ModuleInfo) foreach (info; modul.localClasses) if (info.name == name) return info; return null;

Re: Templates at runtime

2009-02-13 Thread Tim M
On Fri, 13 Feb 2009 17:38:46 +1300, Steve Schveighoffer wrote: On Thu, 12 Feb 2009 21:51:01 -0500, Justin wrote: Is there a way to "find" a classinfo for such a class at runtime? I can't see anything incorrect about what you are doing. Certainly the source for druntime seems to indicate

Re: Templates at runtime

2009-02-12 Thread Steve Schveighoffer
On Thu, 12 Feb 2009 21:51:01 -0500, Justin wrote: > Is there a way to "find" a classinfo for such a class at runtime? I can't see anything incorrect about what you are doing. Certainly the source for druntime seems to indicate it should work. This is probably a compiler bug. -Steve

Templates at runtime

2009-02-12 Thread Justin
I'm trying to instantiate a templated class at runtime and having some trouble. My thought is that since something like "Collection!(int)" will return a valid classinfo, I ought to be able to use ClassInfo.find() and then .create: module test; import std.stdio; void main() { myClass!(