|
| 1 | +- Feature Name: `reserve_delegate` |
| 2 | +- Start Date: 2018-05-03 |
| 3 | +- RFC PR: |
| 4 | +- Rust Issue: |
| 5 | + |
| 6 | +# Summary |
| 7 | +[summary]: #summary |
| 8 | + |
| 9 | +The keyword `delegate` is reserved in edition 2018 and beyond. |
| 10 | + |
| 11 | +# Motivation |
| 12 | +[motivation]: #motivation |
| 13 | + |
| 14 | +[RFC 2393]: https://github.com/rust-lang/rfcs/pull/2393 |
| 15 | + |
| 16 | +The motivation for reserving `delegate` is so that have the option to |
| 17 | +later use it for delegation such as proposed in [RFC 2393]. |
| 18 | +Reserving `delegate` also gives us flexibility wrt. *"omitting the `impl` block"* |
| 19 | +in the future if we wish. |
| 20 | + |
| 21 | +Furthermore, this RFC is motivated right now by the time constraints to get |
| 22 | +the keyword reserved even if the details of [RFC 2393] or similar proposals |
| 23 | +has not been fully fleshed out. |
| 24 | + |
| 25 | +# Guide-level explanation |
| 26 | +[guide-level-explanation]: #guide-level-explanation |
| 27 | + |
| 28 | +The word `delegate` is reserved as a keyword in edition 2018. |
| 29 | +This means that code in edition 2018 can't use it directly as an identifier. |
| 30 | +However, you can always use raw identifiers as in `r#delegate` if you need |
| 31 | +to refer to `delegate`, used in a crate from 2015, from an edition 2018 crate. |
| 32 | + |
| 33 | +# Reference-level explanation |
| 34 | +[reference-level-explanation]: #reference-level-explanation |
| 35 | + |
| 36 | +[list of keywords]: https://doc.rust-lang.org/book/second-edition/appendix-01-keywords.html |
| 37 | + |
| 38 | +The word `delegate` is reserved as a keyword in edition 2018 and added to the |
| 39 | +[list of keywords]. |
| 40 | + |
| 41 | +# Drawbacks |
| 42 | +[drawbacks]: #drawbacks |
| 43 | + |
| 44 | +## It might not end up being used |
| 45 | + |
| 46 | +Simply put, a final accepted delegation proposal *might* not end up using the keyword. |
| 47 | + |
| 48 | +## Edition breakage |
| 49 | + |
| 50 | +[sourcegraph]: https://sourcegraph.com/search?q=repogroup:crates+case:yes++%5Cb%28%28let%7Cconst%7Ctype%7C%29%5Cs%2Bdelegate%5Cs%2B%3D%7C%28fn%7Cimpl%7Cmod%7Cstruct%7Cenum%7Cunion%7Ctrait%29%5Cs%2Bdelegate%29%5Cb+max:400 |
| 51 | + |
| 52 | +Some code will break when transitioning from edition 2015 to 2018. |
| 53 | +Most of this will be easily fixable with `rustfix`. |
| 54 | +However, transitioning between editions will add some churn, |
| 55 | +therefore, we analyse the extent of the breakage and find that `delegate`: |
| 56 | + |
| 57 | ++ is not used as an identifier in the standard library. |
| 58 | ++ is not used as the name of a crate. |
| 59 | ++ is found 19+ times by [sourcegraph]. |
| 60 | + The extent of breakage is fairly minimal. |
| 61 | + |
| 62 | +# Rationale and alternatives |
| 63 | +[alternatives]: #alternatives |
| 64 | + |
| 65 | +A more frugal option to reserving `delegate` would be to reuse `derive` for |
| 66 | +these purposes. However, the keyword fits less well than `delegate` with respect |
| 67 | +to the user's intent where `delegate` fits quite well. |
| 68 | + |
| 69 | +Another option is to simply not use `delegate`, |
| 70 | +however, we feel confident that we should keep this option open to us right now. |
| 71 | +Not doing so would mean that we couldn't use the word `delegate` as a keyword |
| 72 | +for another 3 years or so. |
| 73 | + |
| 74 | +[keyword policy]: https://paper.dropbox.com/doc/Keyword-policy-SmIMziXBzoQOEQmRgjJPm |
| 75 | +[permalink]: https://gist.github.com/Centril/4c82c19b3cb02cc565622a37d1591785 |
| 76 | + |
| 77 | +Furthermore, a recent [keyword policy] ([permalink]), adopted by the language team, |
| 78 | +decided that moving forward, keywords for new features in new editions |
| 79 | +should be real keywords instead of being contextual. The main motivation |
| 80 | +for this was to optimize for maintenance (and reduce technical debt). |
| 81 | + |
| 82 | +# Prior art |
| 83 | +[prior-art]: #prior-art |
| 84 | + |
| 85 | +C# uses the word [`delegate`](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/delegate) |
| 86 | +for something different. |
| 87 | +However, the concept of *"delegation"* is widely used to mean different things |
| 88 | +in different languages. |
| 89 | + |
| 90 | +# Unresolved questions |
| 91 | +[unresolved]: #unresolved-questions |
| 92 | + |
| 93 | +None. |
0 commit comments