Re: Nested functions - better example?

new topic     » goto parent     » topic index » view thread      » older message » newer message

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 -- x  
So sure, in the philosophy of no goto, this gives us yet another way to write convoluted code.

Kat

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu