-
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
RFC: Reserve delegate
as a keyword in edition 2018
#2429
Conversation
Maybe this has been bike-shedded in #2393, but if this is being proposed as a standalone RFC, it's probably worth bringing up here. |
@varkor I agree and share your concern, both on that The best synonyms I could think of are:
but they are not that great. The longest keyword we have right now is |
One possibility is simply contracting, e.g.
Yeah, |
This seems reasonable to me. |
@varkor Not a fan of Attempting a semi-rigorous motivation: We have a few used keywords that are contractions.
Meanwhile, my prediction is that In conclusion, it seems to me that the loss to readability is larger than is made up by improved writing ergonomics. Weighing readability vs. writability, I think we should say that writing ergonomics is something like half as important (hard to quantify, but you get the idea?) as readability. Therefore, I think |
I'm fine with reserving -- my only hesitation, though, is that |
We discussed this in the lang team meeting, and agreed to reserve @rfcbot fcp merge |
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged teams: Concerns: Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
I think that's an acceptable tradeoff — the concept of delegation is already about (a type of) compression, so having a slightly longer word is ok to me. One possible "rescue" is that some potential usage might be closer to how
|
@rfcbot concern value I'm unsure of the value of this. Given that delegate is both a common design pattern (from the GoF book) and idiom, I would expect it to be relatively widely used as an identifier. So the cost to reserving it seems high. Given that in we will almost certainly be able to use a contextual keyword, that delegate is not a great keyword because of its length, and that I'm not at all convinced we need delegation in the language, I think this is a pretty low value (reward/risk) reservation. |
Why guess?
If more data is needed we can reserve the keyword in a PR on edition 2015 and then crater run it.
Sure; but a policy was adopted. ;) is this case particular?
This surprises me; I think it is well motivated feature and a problem for many, as evidenced by it being brought up frequently: |
There's also the fact that making this a keyword requires us to gate any delegation on the 2018 edition. I don't see a reason not to support new features on the old edition unless it makes it substantially more difficult. delegate is used in a position in which we already have contextual keywords ( |
Does it? Can't it be a contextual keyword in 2015 and enhanced to a full keyword in 2018? |
The sourcegraph query only search for item declarations, which I don't think is a good metric. You may declare An upper limit query gives 298/400 search results (including comments and strings), which is far from minimal even if you discount this by 50%. |
I was mostly concerned with breaking public APIs; internal uses should be considered less problematic because it has less of a chain-effect, so it seems to me not a bad metric in that respect. Here's a query looking for
|
This is still an element of user pain which we should avoid if possible.
aiui, that applies to actual features which are in the process of being designed and implemented, not a general policy that we should reserve every keyword which might someday be useful.
I disagree that it is well-motivated, but even assuming there is good motivation there is no consensus at all on what a solution looks like or even if a solution will require a keyword. There are plenty of features around which have had discussion and a few RFCs, but I don't think we want to reserve keywords for all of them, and I don't see why delegation is special here. |
To what extent has using existing keywords instead been discussed? I only found these snippets under Alternatives:
Examples off the top of my head: use self.x as y;
use impl self.x for y;
impl y as self.x;
... |
In past iterations of delegation proposals, But I think that's the only existing keyword that got suggested enough to be properly discussed. afaik |
@shepmaster People could easily find the meaning of the keyword through google, because the docs about the Or the other direction: Someone sees the Also the argument that other languages don't use this keyword doesn't really count IMO. Other languages also don't have many of the other keywords that Rust has. And I don't know any languages that use @Centril I know about the |
I think
I've discussed this here: #2429 (comment)
|
@Centril But in C# Also, please consider my other points I made at the top here (they also apply even if I think delegation / proxying will be used a lot (at least in my projects) so it should have a shorter keyword. And But if we won't end up using |
Now consider this statement: impl TR for S {
delegate * to self.f;
} Clearly, impl TR for S {
use self.f as proxy for *;
} and that's hardly any shorter. And even that doesn't feel quite accurate: |
@repax
|
I googled a bit:
However, I think "proxy foo to self's bar" does not sound natural while "delegate foo to self's bar" does. |
@joshtriplett proposal cancelled. |
@rfcbot fcp close |
Team member @joshtriplett has proposed to close this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
@joshtriplett is the modified keyword policy you're referring to published somewhere? |
TL;DR — the policy doesn't really impact delegation as a feature, just whether or not we'd reserve a keyword in the hopes of the feature being implemented. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period, with a disposition to close, as per the review above, is now complete. By the power vested in me by Rust, I hereby close this RFC. |
It doesn't have to be readable verbatim like a grammatically correct English sentence. So could we also reserve |
🖼️ Rendered
📝 Summary
The keyword
delegate
is reserved in edition 2018 and beyond.🎵 Note
This RFC only aims to reserve
delegate
for possible future use so that we have options.For the (current) main delegation proposal, please see #2393.
💳 Credit
All credit goes to the authors of RFC #2393!