-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
A-arrayArray related proposals & ideasArray related proposals & ideasA-expressionsTerm language related proposals & ideasTerm language related proposals & ideasA-syntaxSyntax related proposals & ideasSyntax related proposals & ideasA-update-syntaxStruct update syntax related proposals & ideasStruct update syntax related proposals & ideasT-langRelevant to the language team, which will review and decide on the RFC.Relevant to the language team, which will review and decide on the RFC.
Description
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.)
gmorenz
Metadata
Metadata
Assignees
Labels
A-arrayArray related proposals & ideasArray related proposals & ideasA-expressionsTerm language related proposals & ideasTerm language related proposals & ideasA-syntaxSyntax related proposals & ideasSyntax related proposals & ideasA-update-syntaxStruct update syntax related proposals & ideasStruct update syntax related proposals & ideasT-langRelevant to the language team, which will review and decide on the RFC.Relevant to the language team, which will review and decide on the RFC.