I've been trying out templates in more depth and one thing I was
wondering was whether template expansions with circular
dependencies might work.
Here is an example that doesn't work:
```d
mixin(A!());
mixin(B!());
void main() {}
template A() {
const char[] A = q{
struct Ar {
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 referen
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:
Err
On Saturday, 2 October 2021 at 08:48:24 UTC, Stephen wrote:
Is this by design?
No but it's easily explainable.
## without mixins
```d
struct Ar { Br b; ubyte a; }
struct Br { ubyte b; }
```
`Ar` semantic starts, members are analyzed, that begins with the
variable declaration `Br b`. `Br` ty
On Friday, 1 October 2021 at 14:03:06 UTC, Stephen wrote:
I've been trying out templates in more depth and one thing I
was wondering was whether template expansions with circular
dependencies might work.
Here is an example that doesn't work:
```d
mixin(A!());
mixin(B!());
void main() {}
templ
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:
Err
On Monday, 4 October 2021 at 11:38:04 UTC, bauss wrote:
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