-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Anonymous enum types (A|B) take 2 #514
Conversation
I like the idea, but I still feel that this RFC doesn’t go into enough detail in a few areas. Specifically:
And I also have a few problems with some details of the feature the RFC proposes:
While I like the idea, and while the parts of the feature that are explained at all in the RFC are explained well, with many examples, I still think that this RFC is lacking detail in some areas. |
For what it's worth, I'm working on another major revision to this feature which includes a more detailed explanation of existing features and will also cover relatively under explained details such as in-memory representation, compilation strategy (especially cross-crate), subtyping relationships, the exact details of conversion and coercion between joins, interaction with type inference, syntax and parsing, and other such topics. |
@P1start To answer you're questions as best I can.
I am not sure at the moment what the exact best way to represent these would be but I expect that at some level, yes the layout of a union is similar to the layout of an equivalent enum.
I do think that it might be possible or necessary at times for two unions that are semantically the same type (i.e. A | (B | C) and (A | B) | C) to be laid out differently with the compiler adding conversions between them when necessary.
Fixed that was just an oversight on my part. the Furthermore I address the necessity of parens in the unresolved questions section, saying I am not sure if they should be required or not. I added them in this example to be more clear. @reem: That's cool. I would love to see it. Also I added some stuff about a possible compilation strategy, although I admit I am not familiar enough with Rust internals to know if it is workable. |
I'd love to have some kind of union type in Rust, they'd be excellent for returning errors. But I disagree with the design here. Unions should just be anonymous enums in the same sense that tuples are anonymous structs, but that's not what this RFC proposes. For example you say:
presumably based on the logic that
This'd be fine for Basically, I get the feeling that if we don't make a
And to instantiate them write:
And then just drop the other fancy stuff like methods on unions or leave it for a seperate RFC. |
See also #409 |
We discussed this briefly in the weekly triage meeting. The original RFC (#402) was closed as postponed, because there is no bandwidth to consider this feature before 1.0. Since there is even less bandwidth available for new 1.0 features at this point, the decision was made to close this RFC PR as postponed, just like the original. We encourage those who are interested in this feature to continue discussing it, just not as an RFC pull request. |
@zwarich My impression was that the RFC was also closed due to lack of clarity on several implementation issues. I filled out a new version of the original RFC last night, and was thinking to post it today even with the understanding it would not be accepted for 1.0. My impression was that the RFC process still works for post-1.0 features, they may just be marked as postponed instead of "will do" or can be accepted as "will do later". Are RFCs not the place to discuss post-1.0 features? |
@reem The original RFC was postponed, which means that we would like until after 1.0 to consider it again. As per the README, a PR on the RFCs repo is a request for an RFC to be moved to one of three states: acceptance, postponement until after 1.0, or outright closure. When an RFC is postponed, there may still be feedback for how to improve the RFC in the future, but that doesn't mean it would be reconsidered before 1.0 if all of that feedback were addressed. The proper place for the discussion of a postponed RFC is a plain issue, not a PR. Disclaimer: this is just my interpretation of the process. |
@zwarich Ok, that seems reasonable. My intention in submitting my new version of the RFC would simply be to get further feedback and see if the feature is in a state to be implemented based on the new RFC after 1.0 - I have no delusions about this feature landing pre-1.0. |
I really liked this idea and have tried to address some of the concerns with it.
rendered
Previous discussion
Thanks to @reem for making the original version of this.