Skip to content

Consider making push/pushfirst/insert widen the type #732

Open
@c42f

Description

@c42f

In #702 (comment) @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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    arraysAbstractArray interface and array operations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions