-
Notifications
You must be signed in to change notification settings - Fork 13.3k
RFC: rename push/pop/unshift/shift to push_{front,back}/pop_{front,back} #10852
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
Comments
I've always had a hard time remembering what |
|
I guess we took |
Off the top of my head
(and leave The main idea here would be make the shifting operations self-describing in both effect and in expense. |
@Jurily: Just because C++ uses the name The reason why I want to make this change is that I want to unify all the sequence types under a common trait. So if/when I make that change, |
@erickt Why should the names chosen for some unified trait like I would think for a particular data-type, you should choose names that convey each methods behavior (in terms of effect, time expense, etc). And then for the unified trait, you would choose names that focus on the end-to-end effect, because the trait presumably won't dictate constraints on O(1) versus O(n), unless it does. :) |
Clojure uses So it might be interesting to have |
A bunch of languages done: C++:
Python:
Java:
Javascript:
Scala:
|
I like simple english words like |
I like the cpp names personally. |
There's also the
|
Is there any reason why we can't have all of the above? Qt has this kitchen-sink approach, it's really nice to not have to guess names. |
@Jurily: There's no need to guess names when you can just hit tab to get a list of the available methods, or look in the documentation. The idiomatic Rust style is to expose as few methods as necessary to provide all of the important functionality, with convenience wrappers for common cases. |
@Jurily Many/most of the duplicated names in Qt only exist in order to be compatible with the STL and STL-conforming templates. Qt itself has its own preferences (which are generally in line with my own). So for completeness's sake: C++/Qt:
We're still missing C#. |
@glehel: Here's C#:
|
I think I like |
Well I guess Java calls it add or append or something like that. Oh well. I still like it. :) |
@nikomatsakis: I'd be fine with that decision. If we do that, then I would suggest that deque-like structures should then get a special python-ish
Although Also, before anyone implements this, I've got a WIP patch that implements most of this, so I'll take care of doing any renaming if/when we decide what to rename. |
I really like this proposition. I think having |
Nominiting. These naming convention issues need to get resolved. |
Accepted for 1.0, P-backcompat-libs. |
This fixes naming conventions for `push`/`pop` from either end of a structure by partially implementing @erickt's suggestion from #10852 (comment), namely: * push/pop from the 'back' are called `push` and `pop`. * push/pop from the 'front' are called `push_front` and `pop_front`. * `push`/`pop` are declared on the `MutableSeq` trait. * Implement `MutableSeq` for `Vec`, `DList`, and `RingBuf`. * Add `MutableSeq` to the prelude. I did not make any further refactorings because there is some more extensive thought that needs to be put into the collections traits. This is an easy first step that should close #10852. I left the `push_back` and `pop_back` methods on `DList` and `RingBuf` deprecated. Because `MutableSeq` is in the prelude it shouldn't break many, but it is a breaking change.
Remove lint name and category fields from the new lint issue form changelog: none Picking a name/category is something the implementers/reviewers tend to cover anyway, I think asking people to come up with it at the time of their suggestion is more of a barrier than it's worth Inspired by the mention in rust-lang#10849
I'm in the finishing touches of adding a
container::MutableSeq
, and I'm realizing it's a bit inconsistent thatvec
has methods likepush()
whereasDList
haspush_back()
. I personally feel that we should rename the vec methods to make it explicit where exactly we are pushing/popping the values. I suggest that we make these following renames:We could also use
append()
andprepend()
forpush()
andpop()
, but I don't like that as much. Or we could rename the DList methods, but I'm also not in favor of that. What does everyone else think?The text was updated successfully, but these errors were encountered: