4 ms·
Which is why the sane way to do it is to have the array-specifier come before the element type: [,][]int crazy; It reads "2-dimensional array of array of in
by Per_Bothner 6y ago
Which is why the sane way to do it is to have the array-specifier come before the element type:
[,][]int crazy;
It reads "2-dimensional array of array of int" in L-to-R order.
Similarly, the type "pointer-to-int" should be "*p" or equivalent.
Unfortunately, history/tradition as well parsing problems make the "sane" solution difficult. One solution is the Pascal approach putting the type after the variable being declared, with a colon between:
crazy : [,][]int;
- Athas 6y agoStrongly agreed! During my PhD I had to design array type syntax for a programming language, and we eventually came up with something similar to that: https://futhark-lang.org/blog/2016-12-09-two-syntax-design-problems.html#array-types https://futhark-lang.org/blog/2016-12-09-two-syntax-design-p...