Thanks. I’ve played around some, but the only working soln I’ve found is to give up on 2D Arrays & only use 1D arrays & then map my 2D In-my-mind array to a 1D Array, e.g.
Map2D(nRow, nCol : Integer) : Integer;
Begin
result := 2*nRow + nCol;
End;
Don’t like it cuz I’m converting a large Delphi Ap to WASM & it has several 2D tables along with a couple of LARGE 4D tables in constant values.
Sorry for maybe dumb query (I’m a newbie), but how do I get the bug-fixed version? I’m programming now using multidimensional arrays. I clicked “check for updates” on Water & it said I was up to date.
Thanks,
–tex
Thanks, guys. I assume the fix will work for any dimensional arrays, e.g. 4D, which I use? Also, I’ve always used “(data )” & saw others use brackets “[data]” for arrays. Is there any reason to use “()” or “[]”?
It seems that the fix will work for at least 4D arrays - the following code runs as expected. I am very happy with that! It allows me to “naturally” initialize vectors, matrices and high dimensional tensors.
class method Main(args: array of String): Int32;
begin
const data: array[0..1, 0..1, 0..1, 0..1] of Integer =
[
[ [[0, 1],[2,3] ], [[4,5],[6,7]]],
[ [[8,9],[10,11]], [[12,13],[14,15]]]
];
writeLn(data[1,1,1,1]);
assert(data[1,1,1,1] = 15);
readLn;
end;
I personally think using brackets for matrices and vectors, are very “mathematically native” (similar to Python), and easier to initialize vector and matrix constants.
I’ve used Delphi for decades & always used paren’s “()” for all arrays of all types & have several such existing in a Delphi Windows Ap that I’m coverting to a WASM, Oxygene Ap. The “()” seem to work; however, I don’t know if oxygene will cause me trouble in the future if “[]” is the preferred way. I hope not.
Carlo tells me we support () in Delphi Compatibility (not a mode I user myself), so that would explain that. If the is the case, support for the syntax won’t go away, no — though I could imaging scenarios where it might be ambiguous, when relying on type inference, eg is:
var x :=(1,2)
an array[0..1] of Integer or a tuple of (Integer, Integer)?