This code doesn't compile, because recursive template expansion.

class Nested(A) {
  A left;
  Nested!(A[]) right;
  this(A l, Nested!(A[]) r) {
    left = l;
    right = r;
  }
}

void main() {
        Nested!int nested = new Nested(1, null);
}

But it successfully compiles in Java an C#. And yes, I know about Java type erasure and C# run-time instantiation.

But is there any reason why D can't follow MLton way - instantiate a class type template ONLY when a constructor of given class is used?

Reply via email to