-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Union types: discriminate across table types and between enums | strings #108
Comments
This will require metatable-equipped records (or objects (or some sort of tagged unions)). For reference, see related discussion in #97.
This will require reifying the enum in the generated code for runtime lookup. Not done yet, but doable. This one seems pretty low-priority, though. |
Considering they're mentioned here, I'll refrain from opening a separate issue for this, but: supporting tagged unions seems very important to me. Coming from a language that supports them, they're rightfully used all over the place, and can make up for unimplemented complex union cases like the mentioned (Regardless, excited about this project! Thanks @hishamhm and all contributors involved for the great work so far. (: ) |
+1, I am embedding Teal in Rust, and the limitation of not being able to use multiple UserData types in an union is a massive problem for me, I have to basically resort to using 'Any' everywhere (mostly metamethods such as Add, Mul etc..) which then defeats the purpose of using teal in the first place :p |
I think a decent compromise would be to allow This should allow people to create their own functions to disambiguate between the variants (which sadly would require |
Half of this is implemented: one can now equip record types with an Discriminating between enums and strings is still to-do! |
As mentioned in the tutorial, the
is
operator can only discriminate across primitive types and at most one table type. The same limitation exists between enums and strings.It would be nice if there wasn't such limitation.
The text was updated successfully, but these errors were encountered: