Re: Nested functions - better example?
- Posted by katsmeow Jan 12, 2021
- 875 views
I used nested functions when i could not goto cleanup code in a procedure, and copy/pasting cleanup code multiple times would break the alloted 64k of ram for a procedure.
procedure x -- declare local vars function cleanup -- process local vars end function -- cleanup -- program x code if blarg then { cleanup | return } -- more program x code if fubar'd, then { cleanup | return } -- more program x code cleanup end procedure -- x
With goto:
procedure x -- declare local vars -- program x code if blarg then goto cleanup -- more program x code if fubar'd, then goto cleanup -- more program x code -- cleanup -- process local vars end procedure -- xSo sure, in the philosophy of no goto, this gives us yet another way to write convoluted code.
Kat