idiomatic D: what to use instead of pointers in constructing a tree data structure?

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jan 7 06:57:42 PST 2015


On Wed, Jan 07, 2015 at 02:52:51PM +0000, Laeeth Isharc via Digitalmars-d-learn wrote:
> Another schoolboy question.
> 
> Suppose I am constructing a tree (in this case it is an AST).  In C I
> would have a pointer for the child to find the parent, and an array or
> linked list of pointers to find the children from the parent.
> 
> Obviously, I could still use pointers, but that would not be
> idiomatic.

Not true. If you're using a tree structure, you *should* use pointers.
Unless you're using classes, which are by-reference, in which case you
can just use the class as-is. :-)


--T


More information about the Digitalmars-d-learn mailing list