michaelbean510
New Member
- Joined
- Aug 22, 2023
- Messages
- 1
Not sure if I'm posting in the right place, sorry if not!
I'm trying to understand local variables on the BBC Micro (not the BBC micro:bit):
DEFPROCexampleproc(J%):LOCAL I%
DEFFNexamplefunc(J%):LOCAL I%
I understand that in the above examples both J% and I% are local, and the global versions of J% and I% will be preserved.
I also understand that if the PROC calls the FN, the FN has its own local variables, and that the variables in the PROC will be preserved.
But what if the procedure calls itself... are the local variables for each iteration preserved or are they replaced each time it is called? Also, how are the original variables preserved—I'm guessing they're pushed onto the stack?
Thanks for any help!
Michael
I'm trying to understand local variables on the BBC Micro (not the BBC micro:bit):
DEFPROCexampleproc(J%):LOCAL I%
DEFFNexamplefunc(J%):LOCAL I%
I understand that in the above examples both J% and I% are local, and the global versions of J% and I% will be preserved.
I also understand that if the PROC calls the FN, the FN has its own local variables, and that the variables in the PROC will be preserved.
But what if the procedure calls itself... are the local variables for each iteration preserved or are they replaced each time it is called? Also, how are the original variables preserved—I'm guessing they're pushed onto the stack?
Thanks for any help!
Michael