GOTO inside a function question? - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16) +---- Thread: GOTO inside a function question? (/showthread.php?tid=1114) |
GOTO inside a function question? - RandomiserUsr - 06-05-2021 I have two functions that have a return 0 Code: FUNCTION processTest(test INTEGER) as INTEGER Does the this cause any memory leaks on the stack? i.e. by not "returning" something is left on the stack and won't be removed? I remember something about GOSUB/RETURN having this or am I okay to not RETURN (I am experimenting before you may say it's not "good practice ) Thanks in advance RE: GOTO inside a function question? - RandomiserUsr - 06-05-2021 (06-05-2021, 03:14 PM)RandomiserUsr Wrote: I have two functions that have a return 0 okay so having changed the code around and no not jumping from a function with a GOTO rather than RETURN, the out of memory errors I was getting have gone. RE: GOTO inside a function question? - boriel - 06-06-2021 (06-05-2021, 09:13 PM)RandomiserUsr Wrote:(06-05-2021, 03:14 PM)RandomiserUsr Wrote: I have two functions that have a return 0 You cannot use GOSUB within a FUNCTION or SUB anymore (it will be forbidden in from version 1.15 onwards). You CAN use GOTO within a FUNCTION or SUB provided it does not jump out of the function scope, otherwise, yes, the stack is corrupted. This will also be forbidden from version 1.15 onwards for the same reason. RE: GOTO inside a function question? - RandomiserUsr - 06-09-2021 (06-06-2021, 10:19 PM)boriel Wrote:(06-05-2021, 09:13 PM)RandomiserUsr Wrote:(06-05-2021, 03:14 PM)RandomiserUsr Wrote: I have two functions that have a return 0 Thanks for the confirmation I have refactored the code so this does not happen again and now no more out of memory issues :-) When's the next release due? thanks |