Closed veritas9872 closed 2 years ago
Duplicate of #1661
The restrict
issue isn't covered by #1661, and it seems orthogonal to multidimensional arrays, so it may be worth starting a separate discussion about that. I'd recommend a discussion to start with, rather than an issue, though.
I would like to ask if first-class support for multi-dimensional arrays would be desirable. C++23 will have native support for multi-dimensional arrays and this has been a feature in many other programming languages, e.g., Fortran, Python (NumPy), Julia, etc. Scientific and high-performance computing are major applications for C/C++ and many tasks from deep learning to graphics require multi-dimensional arrays in their computations. I believe that having a native syntax for arrays would make numeric code much more readable it more convenient to make optimizations to common scenarios. For example, the
restrict
keyword in C, implemented as__restrict
in most C++ compilers, is often necessary for high-performance array code to prevent pointer aliasing. This makes scientific C code much harder to read and may introduce bugs in edge cases where pointer aliasing is necessary. It also makes SIMD code harder to write, requiring pragmas such as#pragma unroll
in simple for loops. I would therefore like to request a native syntax for multi-dimensional arrays and for linear algebra and other numerical/HPC scenarios in general. I believe that it will help make Carbon a great success in the scientific computing community.