rust-lang / rfcs

RFCs for changes to Rust
https://rust-lang.github.io/rfcs/
Apache License 2.0
5.88k stars 1.56k forks source link

Array splicing #374

Open glaebhoerl opened 9 years ago

glaebhoerl commented 9 years ago

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.)

aturon commented 9 years ago

There's perhaps some relation to the splicing proposed for variadic generics.

Centril commented 5 years ago

Triage: @glaebhoerl any thoughts on taking this to the "next level"?

glaebhoerl commented 5 years ago

Thanks for triaging! I don't think I'll have the bandwidth (or, to be totally honest, the desire) to work on RFCs any time in the near future.

Centril commented 5 years ago

@glaebhoerl can you elaborate re. "desire"? is that specific to this feature?

glaebhoerl commented 5 years ago

Nah I just don't have stamina/motivation for the RFC process.

Centril commented 5 years ago

Ah ok; sad to hear that particularly since you always make great contributions.