> I discovered the pointer to the next line wasn't a good idea, because it needed to move every pointer after a line insertion. Huh? Don't you need to only change the "next-line-pointer" for the line that's right before the inserted line? > but the NEXT changed the line, but on the next statement it would lost track and get back to the line following the NEXT. The loops also require their own stack, but including the…
I think you do. Apart from common sense, nothing forbids one from writing stuff like
100 for i = 1 to 10
110 if i = 4 gosub 100
120 print i
130 next
140 return
I think many basics also allowed changing that goto 100 to goto 200 and adding 200 for j = 1 to 4
210 print i
220 print j
230 next
Yes, things would likely end badly, but the basic interpreter would not be smart enough to reject such programs. Its editor didn’t even guarantee that a for statement had a corresponding next or vice versa; all it guaranteed was that the program consisted of a list of lines that each in isolation are valid basic code.