Re: Mutually recursive template expansion

2021-10-04 Thread Paul Backus via Digitalmars-d-learn
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

Re: Mutually recursive template expansion

2021-10-04 Thread bauss via Digitalmars-d-learn
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:

Re: Mutually recursive template expansion

2021-10-02 Thread Imperatorn via Digitalmars-d-learn
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() {}

Re: Mutually recursive template expansion

2021-10-02 Thread Basile B. via Digitalmars-d-learn
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`

Re: Mutually recursive template expansion

2021-10-02 Thread Stephen via Digitalmars-d-learn
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:

Re: Mutually recursive template expansion

2021-10-01 Thread jfondren via Digitalmars-d-learn
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

Mutually recursive template expansion

2021-10-01 Thread Stephen via Digitalmars-d-learn
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 {