Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
William Leue Guru Joined: 03/07/2020 Location: United StatesPosts: 405
Posted: 07:18pm 25 Aug 2020
Copy link to clipboard
Print this post
I have a few questions and/or comments about things that the manual does not cover:
1) I notice that if you use static initialization for a 2D array it puts the successive values in a column-major order. That is, if you do something like this:
option default integer option base one
dim b(2,3) = (1,2,3,4,5,6)
then the values are put into the array like this
1 3 5 2 4 6
as opposed to a row-major language like C.
My question is, does this mean that MMBasic is in fact column-major, or is this just an artifact of the static initialization?
2) Given that static initialization is useful for more than 1D arrays, it is a pity that MMBasic does not seem to support any line continuation characters. I tried the ampersand and underscore continuation characters supported by various other BASIC dialects, but no luck. It would be great if we could get such a thing.
3) The manual says that memory is managed by the firmware using a dynamic heap. I am wondering whether that heap manager has any kind of garbage collection. It seems that there is no way in MMBasic to deallocate memory that has been assigned. Too bad, if available this would solve a number of problems related to temporary data storage in memory.
-Bill
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 4139
Posted: 09:57pm 25 Aug 2020
Copy link to clipboard
Print this post
IIRC it doesn't use a heap and does no GC and needs none.
I'm wondering why you care how arrays are laid out?
John
mkopack73 Senior Member Joined: 03/07/2020 Location: United StatesPosts: 261
Posted: 10:27pm 25 Aug 2020
Copy link to clipboard
Print this post
Always better to lay the Data out the way you want it rather than allowing it to map a 1d array into 2D. Ie you explicitly tell it what to put in (1,1), (2,1), (2,2), etc. that way you know the arrangement.
panky Guru Joined: 02/10/2012 Location: AustraliaPosts: 1116
Posted: 04:19am 26 Aug 2020
Copy link to clipboard
Print this post
option default integer option base 1 dim a(2,3) = (1,2,3,4,5,6) for y = 1 to 3 for x = 1 to 2 print a(x,y); next x print next y
> RUN 1 2 3 4 5 6
> Edited 2020-08-26 14:20 by panky... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!