Identifier (...) is too long by X characters

Tom S h3r3tic at remove.mat.uni.torun.pl
Mon Jul 10 01:10:01 PDT 2006


Don Clugston wrote:
> If Tuple!() works with a nesting level of 50, the limit would have to be 
> pretty big.

Yeah, and it would cause DMD to eat RAMs like a medium-sized dragon.


> Maybe in the future, we'll be able to add some kind of 'final' 
> declaration to templates, which would indicate that they don't need to 
> be stored in the object file or library, and can be discarded from the 
> symbol table as soon as they are instantiated. This would be 
> particularly useful for recursive templates, which can easily spew reams 
> of garbage into the object file.

My thoughts exactly :) Right now I'd be happy with anything that worked 
though...


And while we're at recursive templates, don't you think that the 
limitation for recursive templates, which causes the error 'template 
instance recursive template expansion for template argument X' is pretty 
arbitary ? It can be hacked around, after all:


// tmp.d
import std.stdio;


struct Foo(T/*, int dummy=0*/) {
	Foo!(Foo!(T/*, dummy+1*/)) rec()() {    // line 5
		Foo!(Foo!(T/*, dummy+1*/)) res;
		return res;
	}
}


void main() {
	Foo!(int) a;
	writefln(typeid(typeof(a)));
	auto b = a.rec!()();
	writefln(typeid(typeof(b)));
}
// ----

tmp.d(5): template instance recursive template expansion for template 
argument Foo

But when you uncomment the 'dummies', it compiles and runs without any 
problems...

Yeah, I know, the error is an artifact of how the instantiation works, 
that it's not 'lazy' like in C++. But since it can be fooled into 
working, couldn't DMD apply the hack automagically ?


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



More information about the Digitalmars-d-bugs mailing list