BASIC stack


Author Message
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3364
Posted: 12:40pm 28 Jun 2011      

  Nick said   Does adding more and more commands and functions have a penalty in code execution of the BASIC interpreter?

No, it does not affect the speed or any other aspect (memory usage, etc). This is because the interpreter turns each keyword into a single byte token when the program is loaded. When the program runs the interpreter just uses the value of the token to index to the C code for that particular keyword - this is economical with memory, very fast and allows many keywords without affecting speed. This is also why the interpreter lists keywords in upper case, it is expanding the keyword back to ordinary text.

  Nick said   With so many suggestions coming in, are we redefining the BASIC into a convoluted language?

Yes, this is a worry. User defined functions are part of the ANSI standard for BASIC so I am not inventing anything new with them but other features (such as PIN() and SETPIN) are new and only make it harder for someone to transfer his/her experience to the Maximite.

For this reason I try to resist adding something that is not in Microsoft BASIC or the ANSI standard. A good example is implementing a stack in BASIC, that runs against how the language works and is not part of a standard. However, if the requirement is important enough, there is often no other choice other than inventing something new.

Geoff
Geoff Graham - http://geoffg.net