-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Do we need these in the language?
Currently, dynamic dispatching with interfaces can be used to serve a similar purpose as tagged unions, although some of it is in a work-in-progress state. These cannot serve use cases where we want a generic union; something similar to std::variant
or Result<T, E>
.
Here's some use cases:
Result<T, E>
could be a real type defined in the core library, instead of being an IR-only type with an explicit lowering pass.- In scalar CPU code, it'd make C bindings cleaner, as C unions could maybe be represented as a union in Slang too. This usecase is currently served by generating
property
accessors thatreinterpret
each member into and out of common storage. This is a rare corner case though, and can already be solved, and could impose unwanted limitations on a union spec if taken into account. - Discord discussion where such a type would've been desirable: https://discord.com/channels/1303735196696445038/1373318704372256928/1374175344243900509
Dolkar
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request