On Thu, Jan 16, 2014 at 10:47 AM, Rene Zwanenburg <renezwanenb...@gmail.com> wrote:
> Keep in mind that, unlike in c++, D classes are reference types: > > class Node > { > Node[] nodes; // This is valid > } > > Structs are value types though, so using a struct in the above example is > illegal. That's not true. Indeed: `struct Node { T value; Node[] children;}` is my standard way of having trees in D. The thing is, an array is a reference type and so the compiler is able to determine `Node` size (T.sizeof + a pointer size, or maybe 2, I don't remember which).