4 ms·
Do you have a more complete write-up somewhere? At face value, it looks like something that wouldn’t make it into the C standard, because VLAs were too much for
by klodolph 4y ago
Do you have a more complete write-up somewhere? At face value, it looks like something that wouldn’t make it into the C standard, because VLAs were too much for the standard to bear. It’s also unclear how multidimensional arrays would work—presumably, you would want that to be possible, and distinct from fat-pointer-to-fat-pointer-array.
- WalterBright 4y agoNo, that's all I got, although since it is lifted directly from D, you can get a complete treatment there. VLAs had a poor cost/benefit because they're just too awkward to use. 20 years experience with D shows that the [] syntax knocks it out of the park. Any combination of static/fat arrays can be made for multidimensionality. For example, [..][3] array of 3 fat pointers [3][..] fat pointer to 3 element array [3][3] array of 3 3-element arrays [..][..] fat pointer to array of 3 fat pointers etc.
- klodolph 4y agoI guess what I would want is to be able to have a fat pointer to a multidimensional array, like I can do in Fortran, NumPy, etc. Why is the 1D case special, here? My other questions are how do you create one of these fat pointers, how do you get the length, etc. This sounds to me like VLAs, but with a bigger change to the language, but unable to handle multidimensional arrays. VLAs, for all their faults, at least fit into the language for users well enough that people accidentally use them all the time (not necessarily a good thing).
- WalterBright 4y ago> a fat pointer to a multidimensional array T[3][4][..] a; > length a.length