Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

Rob T rob at ucora.com
Fri Nov 9 09:36:06 PST 2012


On Friday, 9 November 2012 at 14:04:26 UTC, Manfred Nowak wrote:
> Nick Sabalausky wrote:
>
>> So ok:
>> 
>> s/There *IS NO RECURSION* here./There is no _IMPOSSIBLE_ 
>> recursion
>> here./
>
> That's one correection only. Several more are to come.
>
> Sorrily no one seems to have recognized this sentence in
> digitalmars.D.learn:40918:
>
>> Because `R' can recurse infinitely over `Ancor' a mooring and 
>> a way to that mooring is needed.
>
> In regex-parlor this meens, that `( R!Ancor!)*' is the type the
> compiler should be able to handle according to the template 
> definitions
> given.
>
> But the compiler currently can only handle types with a finite 
> length
> of description on instantiation. For me it is in doubt that this
> restriction can be declared as a bug.
>
> -manfred

I'm not sure if you commented on why the non-templated version 
compiled. Since it does compile as I expected it would, it means 
that the templates operate in another dimension from what I was 
expecting, i.e., there's two languages in D, one for templates 
and another for non-temnplate code. My understanding of D from 
what I read, was that templates are supposed to work in the same 
way as regular code. The (T) is only there to introduce a type, 
so that code can be reused over multiple types. What is happening 
however, is that the templates are not doing what would be 
expected if the type was introduced manually, and to me this is 
plain wrong, or at best very unfortunate for D.

--rt


More information about the Digitalmars-d-learn mailing list