Jump to content
IGNORED

Atari FASTBasic question


Recommended Posts

I have started converting many old program to FastBasic 4, and yes it's really in code execution but one thing baffles me. Why does it not support 2 dimensional numeric arrays?

This just doesn't make any sense!  This is a HUGE issue and so many programers use and need multi-dimensional arrays to coding. Having to multiply out indexes to find a position within a single dimension array is a PITA. There's always going to be a problem accessing a value or reading during debugging.

Trying to get away from the HORRIFIC problem on strings Atari's original Basic and now I'm right back where I started.

 

Quickly leaning towards Pascal, Action! or C at this point!!!!

 

Link to comment
Share on other sites

Hi!

On 3/30/2020 at 2:16 AM, developerdude said:

I have started converting many old program to FastBasic 4, and yes it's really in code execution but one thing baffles me. Why does it not support 2 dimensional numeric arrays?

This just doesn't make any sense!  This is a HUGE issue and so many programers use and need multi-dimensional arrays to coding. Having to multiply out indexes to find a position within a single dimension array is a PITA. There's always going to be a problem accessing a value or reading during debugging.

Trying to get away from the HORRIFIC problem on strings Atari's original Basic and now I'm right back where I started.

 

Quickly leaning towards Pascal, Action! or C at this point!!!!

 

 

There is an open issue about 2 dimensional arrays: https://github.com/dmsc/fastbasic/issues/17

 

As to why I did not add support for two-dimensional arrays to the language, it is because FastBasic is designed to be both small and fast - my target is that the integer IDE should always be less than 8KB, and as @Rybags said, it is not difficult to emulate those using index manipulations. Arrays are currently simply pointers to allocated data, like plain C pointers.

 

For implementation, there are two possibilities:

 

1.- You store the "column size" of the array in the memory allocated to the array. This makes all array access slower, currently FastBasic translates A(X) to " DPEEK( ADR(A) + X * 2 ) ", with two dimensional arrays you should translate A(X,Y) to " DPEEK( ADR(A) + (X * PEEK(A)  + Y) * 2 + 1) ", making the access a lot slower - slower in fact that simply emulating the array in your code.

 

2.- You only allow constant values for one dimension. This is faster at run-time, but needs a lot of code added to the parser, as the size of the array would need to be stored in the table of variables during compilation, making compilation slower and the IDE bigger.

 

As the main usage of FastBasic is writing small games, I don't think that this is a major deficiency of the language. So, main question is: Why do you need two-dimensional arrays?

 

If you can post code that needs this, I could better evaluate if it is worth adding support.

 

And do not forget, FastBasic is open source, so you can implement a new feature for yourself!

 

Have Fun!

 

  • Like 5
Link to comment
Share on other sites

Also, I can attest to using multi-dimensional arrays in C using CC65 and whilst it is good while developing you get to a point where the overheads needed to calc the data access are too much and so you end up refactoring to using a single-dimension array instead, so the grass isn't always greener.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...