On Friday, 1 October 2021 at 14:26:39 UTC, jfondren wrote:
On Friday, 1 October 2021 at 14:03:06 UTC, Stephen wrote:
This code should work should mutual recursion be supported.

It still wouldn't work, because structs are value types and it's impossible to say how large either struct is:

Error: struct `mutualrec.Ar` no size because of forward reference

With s/struct/class/ it still wouldn't work because this is a mixin problem rather than a problem of template mutual recursion:

```d
mixin(q{ class Ar { Br b; } });
mixin(q{ class Br { Ar b; } });
```

mutualrec2.d-mixin-1(1): Error: undefined identifier `Br`, did you mean class `Ar`?

This seems like a surprising limitation of mixin, though, which isn't highlighted by the spec.

Actually it is covered by the spec.

See:

https://dlang.org/spec/expression.html#mixin_expressions

It clearly says:

```
Each AssignExpression in the ArgumentList is evaluated at compile time
```

Which means that Br cannot be used in Ar since it cannot be evaluated at compile time during the mixin of Ar.

Reply via email to