-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Rename unshift!/shift! to pushfirst!/popfirst! #25100
Conversation
FWIW I support this change for the reasons mentioned. To me, the less new words a user needs to learn to use the language, the better, and shift/unshift in particular seem to me at least to be historical baggage rather than adding insightfulness. |
Though I prefer
stands. A hopefully broadly amicable tweak that preserves the feel of julia> foo = [1, 2, 3]
3-element Array{Int64,1}:
1
2
3
julia> first(foo)
1
julia> last(foo)
3 such that with julia> pushfirst!(foo, 0)
4-element Array{Int64,1}:
0
1
2
3
julia> first(foo)
0
julia> popfirst!(foo)
0 and likewise for the natural symmetric partners julia> pushlast!(foo, 4) # or push!(foo, 4)
4-element Array{Int64,1}:
1
2
3
4
julia> last(foo)
4
julia> poplast!(foo) # or pop!(foo)
4 Best! :) |
I very much do not care for |
Also, in a world where we finally implement |
I also don't care for |
From the preceding responses, |
d4d1585
to
8defac5
Compare
Excellent, I think we have something worthwhile in |
Also thanks @vtjnash for that hint of prehindsight :-) |
Seems to be in shape apart from the minor conflict in base/deprecated? (Inserting your deprecations at a random location in base/deprecated's body rather than at its ends helps avoid rapidly accruing such conflicts.) Thanks |
Just a quick follow up: why is |
why do you prefer |
I prefer using Also, if people discover |
The docstrings for
To be clear, I lack strong sentiments on |
Ah, I didn't think of this. Thanks for the reply @Sacha0. |
The reason I don't like |
CI roulette has passed. I'll rebase now to fix the conflict. |
8defac5
to
bfbf556
Compare
While being tired and looking at some tests using |
There are a couple of new |
Thanks Tim, I'll rebase and clean those up as well. |
bcdbe05
to
96c7900
Compare
96c7900
to
fafa251
Compare
Triage says 👍 |
Well, perhaps this won't fly, but emboldened by @timholy and @KristofferC's support among other people, here's a possible fix for #23902
Some points of support for doing this:
push!
andpop!
which are widely used and agreed upon terms which apply to many data structures wherepushfront/popfront!
don't make sense.push!
andpop!
, that you can tell whether they're adding or removing elements if you know what push and pop themselves do. This is an improvement on the current state of affairs, where there's really nothing in the name which tells you thatunshift!
adds elements. You just have to know, in addition to knowing aboutpush!
.There's some precedent, with C++ using the namesNot quite, if we're going withpush_front
andpop_front
pushfirst!
andpopfirst!
Perhaps surprisingly, while making some of the changes here manually I kept having to remind myself that unshift (rather than shift) adds elements. So I started again and did most of it with
sed
as a safer option.