I would like to define a set of mutually recursive types.
The simplest way to accommodate this would to have some kind of forward declaration of types. Is this possible?
I can see that this was brought up once https://github.com/JuliaLang/julia/issues/269, but the issue was closed without any action that I can see.
The simplest example would be to represent a grammar that has two mutually recursive sub categories. Consider a language with both expressions (exp) and statements (stmt), with a grammar like.
exp ::= var | f(exp, …, exp), exp + exp, (stmt; stmt; exp)
stmt ::= f(exp, …, exp) | var := exp | if exp then stmt else stmt | while exp do stmt
| begin stmt ; … ; stmt end
The exp (stmt; stmt; exp) allows a user to run a few statements and then return the last exp as the value of the exp. What I want to avoid is mixing categories.
One does not want function calls like f(while exp so stmt). That is the purpose of the separate stmt and exp categories. When we can’t have two types in Julia which both mention each other as internal structures, this only becomes possible by some ugly work arounds. A forward declaration of types would fix. Any thoughts or non-ugly work arounds?.