https://kotlinlang.org logo
b

breandan

01/06/2019, 4:10 AM
@altavir Have you considered using sealed classes / algebraic data types (ADTs) for expressions? The original use case exactly fits building abstract syntax trees of symbolic elements, for example: https://kotlinlang.org/docs/reference/sealed-classes.html https://antonioleiva.com/sealed-classes-kotlin/ See also the original paper on GADTs: https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/gadtoop.pdf
One drawback is the current implementation of ADTs using
sealed
classes is quite restrictive, everything needs to be defined in one file and there are some nesting constraints: https://youtrack.jetbrains.com/issue/KT-13495
a

altavir

01/06/2019, 6:01 AM
One of potential use for expressions is code generation for external langauages like Julia. We will probably work on a limited support for such things. But I don't how far and how fast we will go. I am not sure about sealed classes. I will study that possibility. If you are interested, please write a feature request or I can forget about it.
4 Views