Discussion about this post

User's avatar
Gary Luckenbaugh's avatar

I think this is another anti-pattern that should be avoided, particularly if you want it to be portable across BASICs. I hate to say it, but I feel this should be another NO NO on my list. FOR and NEXT, going back to Dartmouth, was intended to be a lexical block structure. In other words FOR appears at one spot, and there is one NEXT further down in the code. A variable name was required in the NEXT to insure a block structure. NEXT was like a curly brace in C. It was not intended to be an executable instruction. It was intended to close a block.

Expand full comment
Tom Lake's avatar

This problem was eliminated in 1983 (for everyone) and earlier (at Dartmouth). Dartmouth BASIC the Sixth and ANSI/ISO Standard BASIC, have an EXIT FOR statement that keeps the FOR-NEXT stack clean. Even Microsoft BASIC has this command now.

Expand full comment
7 more comments...

No posts