-
Notifications
You must be signed in to change notification settings - Fork 28
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
Semantic clash with Base.insert!
#16
Comments
How about julia> push!(Dict(), :a => 1)
Dict{Any,Any} with 1 entry:
:a => 1
julia> push!(IdDict(), :a => 1)
IdDict{Any,Any} with 1 entry:
:a => 1
julia> push!(Set(), :a)
Set{Any} with 1 element:
:a
julia> push!(Base.IdSet(), :a)
Base.IdSet{Any} with 1 element:
:a |
|
Ah, very good point. Actually,
I think julia> insert!([:a, :b, :c], 4, :d)
4-element Array{Symbol,1}:
:a
:b
:c
:d |
Reading JuliaLang/julia#35513 and JuliaLang/julia#36070, I wonder if vectors should implement |
Good point. The semantic mismatch between |
My thinking here is that |
Agreed. Inserting-into-a-sequence and implicitly shifting the keys (indices) of the rest of the sequence seems like a fairly specialized operation. Not something that many kinds of collection will want to implement, so having a specific rather than generic name for it would be an improvement. |
insert!(dict, k, val)
with a dictionary means something very different frominsert!
with aVector
. The Vector API from Base is more or less sequence- or iterable-like: insert something at a given index of the sequence, and move the remaining values to make room, preserving iteration order.I wondered whether this is an oversight, or whether there's a plan to deal with this in some way?
The text was updated successfully, but these errors were encountered: