DDRM wrote: ↑Mon 22 Sep 2025, 08:24
I guess it was felt useful as a safety check - in general copying one array into another of different shape is not a good idea
But what results is an
error, not a
warning. This is not a compiled language which could alert the programmer to something which is not in general "
a good idea", thus requiring extra care to be taken, but an interpreted language which fails at run time, making it impossible to do it even if it is useful.
There are hundreds of things that you can do in BBC BASIC which can be dangerous, but that are sometimes useful and therefore contribute to the power of the language. For example the ability to write to an arbitrary memory address (indirection) or to call a machine-code routine at an arbitrary address.
Preventing you doing something which might be useful, on the grounds that it is not always "
a good idea", is deeply contrary to the philosophy of BBC BASIC!
your method presupposes the elements are all in a continuous line
That's not true at all. If all the elements of an array are contiguous in memory (which they are guaranteed to be in BBC BASIC) it makes the copy
easier because it can be a straight linear copy, but even if not the interpreter knows the exact layout of both source and destination arrays and could perfectly well perform the copy if not contiguous.
BBC BASIC already has a supported and documented means of copying a one dimensional list of constants into a two-dimensional array, which is surely no different fundamentally from what we are discussing. Would you argue that should not be allowed?
(and of course it will fail if the number of elements doesn't match).
My BASICs fail with an error message if the total number of elements don't match.