-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Forward declarations of choice types #3652
Comments
Presumably the syntax will require the forward declaration to use If a sum-type class could be forward-declared with If we do allow using Even with that restriction, it seems a little messy to have cases where there's an arbitrary, formally meaningless choice between |
One interesting consequence of changing the adapter syntax from Syntactically, our approach up to now has been that the portion of the definition from the
... but given that
This gives us immediate syntactic support for putting access specifiers on the alternatives, adding other member names including member functions to choice types, and so on. (Presumably we wouldn't permit a class to have both |
Regarding the latter syntax in particular, I tend to think of the union format that For comparison, reordering other declarations (e.g., Also, depending on how much you try sharing syntax, while |
If we go that route, it might be nice to take it one step further, and have an evolution path where you can customize the representation while leaving the
That's not great, but it's a gesture toward the kind of thing I mean. If not for that consideration, I would much prefer your other suggested syntax:
That keeps all the alternatives grouped together, which I think will be helpful for readability if the definition can contain other things like member functions. But maybe we can get the best of both, somehow?
We don't have a design for making the discriminator visible in the API (short of doing a full custom implementation) but we'll likely want that at some point, for interop/migration purposes. However, I think it should require the type to explicitly define the discriminator values, rather than have them be inferred based on the order.
I think we'll very likely want untagged unions, but trying to share syntax between them seems like it will impose a lot of cost for little benefit. The problems they need to solve don't have much overlap. |
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please comment or remove the This issue is labeled |
Currently, there is no suggestion in the design that choice types support forward declarations, and the toolchain implementation consequently does not support forward declarations of choice types. So:
class
orchoice
?I don't think there are any novel issues with choice type declarations that don't apply to classes. But the second question seems like it might deserve a little thought.
The text was updated successfully, but these errors were encountered: