GOTO
I have an idea for a restricted goto:
1. A label would be allowed only immediately before or immediately after a
loop termination (end for or end while) statement.
2. A label could be branched to only from within the loop, including nested
loops:
for i=1 to 50 do
-- some statements
while 1 do
-- lots of statements
if x=1 then goto continue_while end if
if x=2 then goto continue_for end if
if x=3 then goto exit_while end if -- could use exit here
if x=4 then goto exit_for end if
-- lots more statements
continue_while:
end while
exit_while:
-- more statements
continue_for:
end for
exit_for:
-- rest of program
This would simplying nested loop coding while virtually eliminating
potential abuse. Note that only the case where x=3 is now doable without
flag variables, etc. I believe this is much more readable than flags.
How difficult would this be to implement?
-- Mike Nelson
|
Not Categorized, Please Help
|
|