Open mmcdon20 opened 2 months ago
It's not allowed because it's impossible to represent the extension-type erased representation type in the current Dart type system. Dart would have to add recursive types to the type system before this would be possible.
So this is not an alternative to recursive type aliases, it's basically the same feature, and if we have recursive types in the type system anyway, we might as well allow them in general using recursive type aliases.
This is kind of an alternative to allow recursive typedef.
This would allow for recursive data structures backed by records such as in the following examples:
This would also allow for recursive
Function
definitions, such as in the following example:If union types are also added, then you could potentially represent a Json type this way:
The above definitions could potentially be improved further if allow extension type to implement Record and Function types, and/or implicit coercion through implicit constructors are also added to the language.