Quantcast
Viewing all articles
Browse latest Browse all 2548

programming • Re: Optimisation

I wasn't sure if the compiler has to do some sort of lookup table for the variable to get the number before it can use it.
The interpreter (not a compiler) maintains a linked list of variables so, yes, there is a minor impact. But as BigEd says, it's only evaluated once in the FOR loop, not each time round.

In fact it's a little more complicated; BASIC maintains _multiple_ linked lists, one for each starting letter; so there's a linked list for variables begining "A", a linked list for "B" and so on. This can make it pretty quick to look up variables because the linked lists may be pretty small (as long as don't start all your variables with the same letter!). These variables are all stored on the HEAP, starting at LOMEM.

There _are_ faster integers; A% to Z% are at known fixed locations (A% is at &404, B% at &408 etc etc) so using those 26 integer variables is faster. (Note: A% to Z%, not a% to z%; the lower case ones are regular variables on the heap).

Statistics: Posted by sweh — Wed Dec 04, 2024 2:52 pm



Viewing all articles
Browse latest Browse all 2548

Trending Articles