Closed caub closed 3 years ago
Assuming Tuples already existed, that would already be the same as:
const t = #[a, b];
arr[t]
iow, inside the brackets, any expression is already legal - so the only syntactic options are something that’s a syntax error already in expression position. So, for your syntax to work, Tuple syntax wouldn’t be able to.
@ljharb arr[#[0,2]]
would be valid syntax when tuple are added in the spec. I was thinking that the spec could then allow a special behavior for array[tuple]
since tuples are new, there would be no backward-compatibility issues.
But after more thoughts, this syntax is heavy anyway, it doesn't look that appealing
There would be consistency issues, though.
ok, thanks, closing
The benefit is to not introduce new syntax
Tuple proposal: https://github.com/tc39/proposal-record-tuple
This idea comes from @brigand
What do you guys think about using tuples notation for this proposal? They'd be used in arrays property accessors, and return a slice