On Thursday, 8 November 2012 at 18:45:08 UTC, Manfred Nowak wrote:
Rob T wrote:

I want to be clear that I'm trying to define a recursive data structure
[...]
so correct me if there's a reasonable way to get this job done

A recursive data structure needs a mooring ... and such a mooring is
missing in the code given.

-manfred



I'm afraid I don't follow what you mean by mooring and anchor given the example at hand.

The structure as described allows for the implementation of a real-world useful structure, such as a property tree, where a value may have an associated list of sub-values, (recursive) forming a tree of values. The list of associated values is of arbitrary length and a d-list is not necessarily required, so long as it's a list.

This is a simple yet very usefull structure, which I can define apparently legally in D so long as I do not make use of a template. If I can define it legally without a template, then I expected to be able to define it with a template.

Obviously infinite recursive structs cannot be allowed, and dmd does detect these cases. In my case, the struct that implements the list contains nothing but pointers, therefore it should allow for lists of lists, and indeed it does, but only if I do not use templates OR I use templates but also change the payload to be a pointer.

Why the difference in ability to compile as a template vs a non-template if the all of the template structures can be completely resolved into defined states during compile time - just as it would be if I hard coded the same types?

--rt

Reply via email to