Skip to content

Array splicing #374

Open
Open
@glaebhoerl

Description

@glaebhoerl

Analogously with functional struct updates, we could also allow "functional array updates", or in other words splicing of fixed-length arrays:

let a: [int, ..3] = [1, 2, 3];
let b = [..a, ..a, ..a];

Here b: [int, ..9]. Unlike FSU, there can be any number of array splices in any positions.

This has some syntactic overlap with replication:

let c = ['c', ..10];
let d = ['d', ..x];

but even the latter case can always be disambiguated based on the type of x (it's either an integer or an array; it can't be both).

(Also, we may want postfix rather than prefix .. in this case, removing the overlap completely. But we should also want that for FSU.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-arrayArray related proposals & ideasA-expressionsTerm language related proposals & ideasA-syntaxSyntax related proposals & ideasA-update-syntaxStruct update syntax related proposals & ideasT-langRelevant to the language team, which will review and decide on the RFC.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions