You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduce a concise syntax for declaring fixed-length tuples consisting of a single repeated type. For example, instead of writing [number, number, number, number], allow [number: 4] to represent a tuple of four numbers.
π Motivating Example
Current syntax for fixed-length tuples requires repetition. This can be a bit awkward if the tuple has many elements:
Isn't proposed syntax already used for named tuples? Example should create length 1 tuple with element named number and type (literal) 9.
Yeah you are definitely right, I didn't pay too much attention to the syntax, it's just a placeholder. I'd be totally happy with a better syntax for the same semantics (say, [number; 9] like rust's fixed-length array declaration).
Unfortunately the author of that issue did not come up with a good real world example. In the maths/CG area this could be much more a real QoL improvement.
typeTupLen<Nextendsnumber,T=any,AextendsT[]=[]>=NextendsA['length'] ? A : TupLen<N,T,[T, ...A]>;declareconstx: TupLen<5,number>;// same as [number, number, number, number, number]typeMatrix3x3=TupLen<9,number>;
Activity
IllusionMH commentedon Sep 24, 2025
Isn't proposed syntax already used for named tuples?
Example should create length 1 tuple with element named
numberand type (literal)9.MartinJohns commentedon Sep 24, 2025
Duplicate of #47874.
hillin commentedon Sep 24, 2025
Yeah you are definitely right, I didn't pay too much attention to the syntax, it's just a placeholder. I'd be totally happy with a better syntax for the same semantics (say,
[number; 9]like rust's fixed-length array declaration).hillin commentedon Sep 24, 2025
I knew there would be an existing issue!
Unfortunately the author of that issue did not come up with a good real world example. In the maths/CG area this could be much more a real QoL improvement.
snarbles2 commentedon Sep 24, 2025
The linked issue points out this is something you can create yourself with code example included.