JuliaArrays / JuliaArrays/StaticArrays.jl

Consider making push/pushfirst/insert widen the type

Open
#732 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

arrays
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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.