-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Labels
Description
This is a thing lacking in all Atari Basic implementations, ability to define functions. (same as PROC defines rubroutines)
https://zxbasic.readthedocs.io/en/docs/function/
I propose using the stack for being able to do recursive functions, if local variables are too complex, this implementation uses only parameter copy.
That allows for shorter code. eg
160 XX=X+1:EXEC HS:HS1=V:XX=X-1:EXEC HS:HS2=V:XX=X+3:EXEC HS:HS3=V:XX=X-3:EXEC HS:HS4=V
170 YT=(H-L)*HS1+(R-H)*HS2+(L-W)*HS3+(W-R)*HS4+W
becomes
170 YT=(H-L)*HS(X+1)+(R-H)*HS(X-1)+(L-W)*HS(X+3)+(W-R)*HS(X-3)+W