IntyBASIC icon indicating copy to clipboard operation
IntyBASIC copied to clipboard

Local variables

Open artrag opened this issue 7 years ago • 0 comments

In a similar way to what you have done for local labels, you can add local variables. A possible implementation could be that variables starting with a dot within a procedure get as prefix the name of the procedure. You could also add a qualifier to identify temporary variables that do not need to retain their value between two calls of a function (or simply detect them from the code logic), and reuse automatically the ram allocated for them. If you go for automatic detection this implies that the compiler has to scan the three of the calls and make sure that the ram used in a procedure does not overlap the ram used in another procedure called directly or indirectly by the former one.

Another option is to use a sort of namespace command or module command and add to the variables starting by dot the a specified name as prefix. This is a solution to reuse a whole file in a different project. Automatic Ram reuse becomes more difficult. You should explicitly allow the coder to specify which variables or namespace are allowed to use the same area in ram. You need a sort of union command (as in C).

Or something like Dim x(10) Dim y(10) at varptr x(0)

To get x and Y in the same ram locations

artrag avatar Dec 30 '18 15:12 artrag