-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
API conventions cleanup #16436
API conventions cleanup #16436
Conversation
r? @brson |
The details of the new conventions can be found on discuss: http://discuss.rust-lang.org/t/settling-some-key-naming-conventions/269/35 and in the guidelines: http://aturon.github.io/style/naming/README.html This is a: [breaking-change]
The details of the new conventions can be found on discuss: http://discuss.rust-lang.org/t/settling-some-key-naming-conventions/269/35 and in the guidelines: http://aturon.github.io/style/naming/README.html This is a: [breaking-change]
match new conventions The details of the new conventions can be found on discuss: http://discuss.rust-lang.org/t/settling-some-key-naming-conventions/269/35 and in the guidelines: http://aturon.github.io/style/naming/README.html This is a: [breaking-change]
The details of the new conventions can be found on discuss: http://discuss.rust-lang.org/t/settling-some-key-naming-conventions/269/35 and in the guidelines: http://aturon.github.io/style/naming/README.html This is a: [breaking-change]
When did this call get made? Last activity I saw on the discussion, it was not settled. Also of note, #9784 never even mentions the name |
Also of note, the commit that updated the guidelines to talk about |
The decision was made during an API stabilization meeting, which is the current process for guideline acceptance, and took into account all of the feedback from the discussion. |
As an aside, if you're looking for a bit more discussion on it, the |
See #13159 (comment) in particular. |
Where are the minutes for this meeting? rust-lang/meeting-minutes only contains 3 API review meetings, and none of them mention unwrap/assert (nor do the weekly meetings). |
I hadn't realized @brson was posting those -- I will make a PR with the notes from that meeting. |
I'm going to bed right now, but I'm really concerned here that you're changing the name of what's probably one of the most widely-used APIs, without any clear precedent for the name (I get the argument for moving away from Basically, it feels like this is a decision by fiat, and it makes me very uncomfortable and feeling like the concerns I raised on the Discourse forum were never properly addressed. I would really appreciate it if you could hold off on the |
Minutes PR is here: rust-lang/meeting-minutes#2 "Minutes" is a bit of an overstatement, though -- at API review we generally log the decisions but not the conversation, which would be a significant effort to transcribe. I can look into the possibility of transcriptions for Guidelines discussions in the future, although the idea is that we only have such discussions when there's already a pretty clear consensus on the team. In the meeting, I made sure that the main arguments against I strongly disagree that this is an opaque process. We had substantial discussion on Discourse -- which was announced as the official venue of Guidelines discussion. Several perspectives were given and points rebutted. Every decision involves tradeoffs, and hence every decision has downsides. The downsides you pointed out about |
Have you tried how a longer piece of code looks like with |
I strongly disagree with this change.
|
This is a good thing? When code reviewing, I see a crappy code with constructs like We should regard the use of |
I think naming something |
Do I understand this correctly: Why not simply |
As another general point, one rarely sees @arcto Both of those |
@huonw I guess that renaming it to something like |
Has anyone considered using 'ensure' instead of 'assert'? I've seen that used in APIs before. Sorry to add to a naming discussion... |
Renaming it to something much longer and more cumbersome, like @huonw I'm in agreement with you that this should be used less frequently, but that doesn't mean that it isn't used a lot now and that doesn't mean that this isn't a huge breaking change for marginal benefit, especially with an unclear and confusing name like I also echo @kballard s concern in that this process seemed a bit opaque - there was lot discussion but mostly disagreement among the community, and to see something this common changed almost silently is pretty weird. |
Coming from Haskell I have to say that this doesn't make much sense to me either.
As for the |
When writing C++ the standard practice, for some years now, has been to assume that anything might throw an exception, unless when explicitly stated otherwise -- i.e. when the function has been explicitly declared exception safe ( The community has reversed its previous position on exception specification. In fact, it was deprecated in C++11. I think we should learn from this and realise that the same circumstances apply to Rust. Any function might fail for any reason (due to its implementation/environment/etc) unless explicitly marked as safe. IMO Rust lacks in this regard. The safe position is to assume that What is needed above and beyond this is means to guarantee no fail, as well as transaction safety, analogous to the strong execption safety guarantee in C++. |
That doesn't make it right or something that we shouldn't try to address now, before use of Rust really kicks off.
(That was exactly my point in this comment.)
Both of these statements are wrong; the discussion on discuss has
|
Coming from OCaml, this whole discussion strikes me as crazy; it's like Rust's type system makes a tradeoff between ceremony and robustness, and some people want a different tradeoff. Is there really a need for a language-wide mechanism for checking whether an option type has a substantive value or a "none"? People can roll their own pattern match; they're less likely to make mistakes that way anyway |
@mk270 you may be misunderstanding this discussion? The discussion about |
Many members of the Rust community (even Mozilla employees) have expressed (strong) disagreement here and on Reddit and i don't think their input was honored in the preceding discussion and voting. It's one thing to invite a community to discuss matters and then decide one way or another. But it's a different thing when you discuss and vote without people knowing about it and without giving them a chance to give input. |
|
@kud1ing I wasn't going to comment (since I try to avoid using
AFAIK a lot of important discussion (and a lot of bikeshedding) is happening on Discuss right now. It's sort of the development forum. Among that was discussion of this change. I think Mozilla needs the power to make decisions and keep the language moving forward. As a member of the community I agree with @pcwalton and support the benevolent oligarchy waving its hand on this one.
|
Huuuuuge 👍 here. Not everyone will be happy with every change. It's important to take feedback into consideration, and to take comments seriously, but that doesn't mean the language is or should be designed by upvote. |
I also agree with @pcwalton 's statement that the process here is not "opaque", and that sometimes a decision by "fiat" is sometimes necessary (and that this is probably one of these cases). I chose to voice my opinion about this change on the discuss forum, but I absolutely do not want that comment there to be used as some sort of basis for blocking the Pull Request here. |
We can't honor everybody's input, or we won't be able to make any changes except the simplest, most uncontroversial ones. There have been many times where I've strongly disagreed with changes and they were made anyway. I don't mind that—that's part of software development. |
Now, this might just be me, but I don't actually get the huge controversy. Nobody is disagreeing with the sentiment of the change, but saying (and I agree) that That said it seems to me most people agree that The only real argument I have heard against reconsidering the name is "But we decided this at a meeting", which honestly seems a bit childish. I get that this can lead to bikeshedding, and that it needs a dictated decision, but I feel that choosing the one name that has lots of valid arguments against it, instead of any of the others, is misguided. |
Assert would be a terrible name for this method; whoever came up with it seems to be ignoring every other programming language out there where assert means "ensure this is true", not "ensure true and return a value", as well as English itself. There's too much conventional wisdom around and experience with what assert means and none of that includes returning a value, which is the primary use case for the method (the fact that it fails if there's no value is a secondary concern to pretty much every single user). |
I am also very negative on
I think that |
It would be cool to see a community Poll (perhaps on reddit) in controversial occasions like this, where people add suggestions and everyone can place a vote - not to try and get some gospel answer but at least just to see if something generally agreed upon manages to rise to the top. |
IMO... I was perfectly happy with .unwrap(). C++ calls it '.value()' or '.value_or()'. swift calls it ! ... the interesting thing is they deem it important enough for an operator. A short word like 'unwrap()' is a nice compromise. If changing it, consider just making it the same as C++. (or the world could put effort into renaming .value() .unwrap()) Its not the same as 'assert'. You know its potentially none, so in the absence of 'else' its easy to deduce it must have a fail case. |
Currently we can grep for I think that assertions are more desirable than unnecessary unwrapping. Therefore we want to distinguish both. With |
+1 for |
For what it's worth I strongly agree with @llogiq
myOption.force()
myOption.or_fail()
myOption.or_bust()
myOption.yes_really()
myOption.is_not_an_option()
myOption.or_your_money_back()
unwrap, fail, assert whatever, I think they should avoided at all, so I vote for: |
While |
As far as I'm aware, the primary motivator for changing My counter is that |
I already posted this on the Reddit thread, but I just wanted to put in my two cents here. Has I agree with the reasons above for not using |
Some other ideas:
All of those could also begin with |
Clearly, this is a controversial topic. Our original plan (see "Consensus and Decisions") was to use Discuss as the forum for discussing guidelines. We thought that the relative consensus on the Discuss thread reflected general agreement. Instead, it seems that a lot of people were just unaware of the proposal. So we're going to amend our plan for developing guidelines. We can still have discussions on Discuss but afterwards we'll prepare an RFC summarizing the results. Of course it's often not possible to reach complete consensus, and in those cases it's ultimately the responsibility of the core team to finalize decisions and ensure they fit the overall design. In this case, that means we can close this PR and @aturon will prepare a formal RFC describing the proposed changes and also putting them in a larger context. We will decide on this RFC in the weekly meetings as normal. I want to emphasize an important distinction between guidelines and library stabilization. As I said, we'll use the RFC process for general guidelines that affect multiple libraries. But we will continue to use the stabilization meetings to make small-bore decisions about individual libraries, such as renaming methods for consistency or removing methods that receive little use. For those sorts of cases, a full RFC is overkill. |
While I don't feel terribly strong feelings about it, I do feel that using Furthermore, if we really want to discourage this pattern, I'd be okay with removing the method altogether and making the programmer type
|
Thank you. This is a very reasonable solution. |
@nikomatsakis Thank you. That sounds like the right way to move forward. |
In Rust we trust 👍 |
-1 to -1 to opaque process: you (the core team) make this decision and discuss it in the corner (not many people use discuss.rust-lang.org, why not post to reddit or rfcs before this change? ). |
@liigo Before responding with such an inflammatory note, it behooves you to at least look to see if there was a comment added when the issue was closed to see if your concerns have been addressed. Which there was in this case, in particular this response from @nikomatsakis : #16436 (comment). (Better still, read over the entire comment thread, if that is feasible.) This is not the first time your comments have reflected a lack of effort on your part to read over the general context before adding your two cents. I can understand not reading every comment in a long thread, but in this case and others, you have been particularly rude. |
@pnkfelix I apologize for my last comment (and maybe old ones), if you think it's "particularly rude". I'll make sure never leave rude comments, I promise. So don't ban me or put me into the blacklist or something else, please! I still want to be active in the Rust community. As a note, I did contribute to Rust source, docs and issues in the past, e.g. the latest #16448 / #16928. The following is some explain for my last comment (both -1 has its reason in original comment already): The core team posted on discuss first and quickly made decision only two days later without public meeting report (which was delayed merging for about two weeks). Both the post and the api meeting did not explicitly claim renaming |
@liigo I don't think pnkfelix has the power to "ban you" or "put you into the blacklist." Even if he did, I doubt it would be exercised. As long as you're a helpful member of the community, people will be happy to have you around. In particular, I don't think you need to justify yourself based on your contributions - those actions speak for themselves. However, everyone participating in this thread is well-aware of all of the points you brought up: they're the core issue at hand, and the reason for nikomatsakis' resolution above. So you're not adding anything to the discussion by simply restating/summarizing the core controversy. Especially in this case - where the issue has been acknowledged, and a long-term solution agreed upon by the core team. So pnkfenix has a point here: developers dedicate time and energy to reading your posts and placing them in the context of an entire issue. The bare minimum respect you can have for others' time is to read the threads carefully before commenting. This makes the best possible use of everyone's time, including your own, since you won't have to deal with people complaining when you want to get your opinion heard. |
Thank you @nathantypanski . I hope that @liigo will understand your note; I'll refrain from commenting further on the matter for now. |
Thanks, @nathantypanski , I do understand your note. This issue was closed, I no longer comment here any more. |
This PR performs several widespread renaming to bring a number of APIs into line with new conventions.
The details of the conventions can be found here and in the guidelines.
The most important changes are:
unwrap
operation onOption
andResult
is now calledassert
.get_ref
,get_mut_ref
, andtake_unwrap
methods onOption
are deprecated.iter
,iter_mut
, anditer_owned
.mut
variants universally use a suffix_mut
rather than a prefix.There were also a few more minor renamings.
Closes #13660
Closes #13159
Closes #9784
All the original functions remain available in deprecated form. Nevertheless, this is considered a:
[breaking-change]