Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

19
  • 1
    Very interesting. Someday I'll have to figure out how they did that... normally an interpreter wouldn't know where to go if the test fails immediately, so either they do a lookahead or they top test and then roll forward to the NEXT instead of the other way around. Commented Apr 23, 2022 at 20:23
  • 2
    @MauryMarkowitz - I don't see why being an interpreter prevents a scan over the source code before execution starts. Commented Apr 23, 2022 at 22:12
  • 1
    @MauryMarkowitz: there's also no requirement to scan up front. You could do something like have a flag indicating "I'm in a dead for loop" which reads but doesn't execute code. You stay in that mode until you get to the corresponding NEXT (so you'll probably need to stack dead FOR/NEXT pairs) then turn off the flag. Not how I would do it, I'd prefer pre-scan to speed things up. Commented Apr 23, 2022 at 23:50
  • 3
    I understand the hesitation, but finding the closest NEXT forward shouldn’t be fundamentally harder than implementing GOTO to a forward line number. Commented Apr 24, 2022 at 0:12
  • 3
    @paxdiablo: "When the value of the simple variable passes the final value": the initial value has already passed the final value if N=0, so the loop is never entered. Commented Apr 24, 2022 at 2:22