Re:Rust 1.50
by steveklabnik on Thursday February 11, 2021 @11:20AM
(#26103352)
... and in some sense, tuples are also isomorphic to structs.
Product types: woo!
Re:Rust 1.50
by andrewflnr on Thursday February 11, 2021 @11:57PM
(#26110884)
There's at least one language (Haxe?) that uses exponentiation syntax for array types, playing in the product type idea: (A,A,A,A) = A^4
In theory, arrays do not need to exist, and could in theory be expressed as tuples, but that would lead to rather unpleasant syntax. `(A, A, A, A, A, A, A, A, A, A)` is certainly not as nice as `[A; 10]`; — Rust could even have chosen to make the latter syntactic sugar for the former and make them interchangeable.
The crux to this, is that in Rust, unlike in many other languages, the length of an array is static and known at compile time. Many languages lack such a datatype, as it isn't strictly needed per the aforementioned reasons.