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

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


Sean Kelly wrote:
> I don't know.  To do so would be like allowing:
> 
> struct S
> {
>     S val;
> }

Umm... not quite. In your case it's just a plain nested, recursive 
struct which is obviously impossible. In my case:

struct Foo(T) {
     Foo!(Foo!(T)) rec()() {
         Foo!(Foo!(T)) res;
         return res;
     }
}

When the function template is instantiated, one more nesting level is 
'added' and a non-recurring struct is returned. The compiler reports an 
error because somehow it doesn't instantiate the 'rec' template lazily. 
In the example you've given there's an infinite theoretical nesting, yet 
in the version with the function, infinite nesting isn't possible, 
because the nesting increases one level with each 'rec' instantiation. 
IIRC, that's perfectly legit in C++ as it uses a different method for 
template instantiation.


> I'm not sure I'd want the compiler to try and "fix" a mistake I'd made 
> involving this.  Adding an integer is pretty easy anyway.

Easy ? It's undocumented, tedious and generally weird. It might stop 
working in the next compiler version because I'm not even sure why DMD 
allows it.


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



More information about the Digitalmars-d-bugs mailing list