Architecturally Brandy must be very different from either my BASICs or ARM BASIC in the way it implements LOCAL arrays. In my BASICs, and I think in ARM BASIC too from the way it behaves, LOCAL arrays are stored on the stack - the same stack that is used to store the control information for a FOR...NEXT loop. That means it is impossible to DIMension a LOCAL array inside a FOR...NEXT loop, because when the NEXT statement is reached it will find the array on the stack, not the information it expects!Soruk wrote: ↑Sat Jul 24, 2021 2:24 pmthat was a slightly different issue of an array seemingly losing its LOCAL-ness after being dimensioned in a sub-procedure (an issue that doesn't arise in Matrix Brandy, instead I get an error that array has already been dimensioned the second time PROCsetup is called
Admittedly my BASICs behave differently from ARM BASIC in respect of what happens if you try it. In mine, the NEXT statement will invariably fail with a 'Not in a FOR loop' error but in ARM BASIC this will only happen if an explicit variable is specified after NEXT, e.g. NEXT i%. If NEXT is used without a variable it will apparently succeed, but the array will be silently discarded.
In Brandy, however, it seems that the NEXT statement actually succeeds, and the LOCAL array survives, despite it having been dimensioned inside the loop! I have no idea how that is even possible: are LOCAL arrays not stored on the stack, or are there different stacks for LOCAL arrays and FOR loops, or what?