JuliaArrays / JuliaArrays/StaticArrays.jl
Consider making push/pushfirst/insert widen the type
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 844
- Forks
- 159
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 3
Description
In https://github.com/JuliaArrays/StaticArrays.jl/pull/702#discussion_r379281256 @tkf suggested that it would be helpful to have push promote the type. I'm opening this issue because while it's easy to implement I don't have a strong feeling for the benefits and drawbacks.
The main drawback I see is that it's quite different from push! and might be surprising if b = push(a, element) gives b with a different eltype from a.
But other than quibble it seems natural for functional manipulation of immutable data structures if the type is promoted. (Wrinkle: for consistency with StaticArrays constructors this would have to be promotion via promote_type rather than pure widening, otherwise we'll quickly get abstract types in numeric code.)
If we did this, we should also make pushfirst and insert the same for consistency.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked pull-request discussion and review the current behavior of push, pushfirst, insert, and push!. Compare their type-promotion behavior and the StaticArrays constructor conventions mentioned in the issue. Done means reaching and documenting a decision about consistent behavior for all three functional operations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100