cowgol icon indicating copy to clipboard operation
cowgol copied to clipboard

Dimension declarations in 2D arrays reversed?

Open ibara opened this issue 4 years ago • 4 comments

Hello.

Here are two programs that ought to be equivalent, one in C and the other in Cowgol: https://github.com/ibara/cowgol-utilities/blob/main/2darray.c https://github.com/ibara/cowgol-utilities/blob/main/2darray.cow

However, they are not equivalent. The output from the C version is what I would expect but that is not the output from the Cowgol version. To get the expected output from the Cowgol version, swap the dimension index declaration on line 6. That is, put XMAX before YMAX in the Cowgol version, even though all other accesses are in the form [y][x].

This is a bit unexpected, so bringing it up in case it is not intentional.

Discovered when writing a Game of Life implementation in Cowgol.

ibara avatar Dec 03 '20 03:12 ibara

Oh, interesting. That's not actually supposed to work! I've just had else on another forum complain about only having single-dimension arrays, too...

I will look into this; it's clearly almost working so it would be good to regularise. Thanks for the test case.

davidgiven avatar Dec 03 '20 09:12 davidgiven

Did not check the source but dare to ask anyway - is this already supported?

dumblob avatar Oct 18 '23 19:10 dumblob