I don't find this surprising at all. Being able to edit code that's currently being run would open up a huge can of worms.
Here's an example loaded into slot 0, with line numbers for clarity:
1 PRINT "HELLO" 2 GOSUB @FOO 3 PRINT "WORLD" 4 END 5 6 @FOO 7 PRGEDIT 0,2 8 PRGINS "PRINT 123" 9 RETURNThe question here is, where does @FOO return to? Typically, GOSUB @FOO would push a pointer to the stack which points directly after it, then jump to @FOO. Then, when RETURN is reached, it pops that pointer off the stack and jumps back to right after GOSUB @FOO, where it can execute the next instruction. For simplicity, let's say it works with line numbers, so it pushes 3 to the stack. Then, stepping through it, this is what happens:
- "HELLO" is printed.
- 3 is pushed to the stack, and the program jumps to @FOO.
- The line "PRINT 123" is inserted before line 2, shifting everything below it down a line. Now the program looks like this:
1 PRINT "HELLO" 2 PRINT 123 3 GOSUB @FOO 4 PRINT "WORLD" 5 END 6 7 @FOO 8 PRGEDIT 0,2 9 PRGINS "PRINT 123" 10 RETURN
- 3 is popped off the stack, so it returns to line 3... which is now GOSUB @FOO again. Uh oh.
- And it just keeps going in an endless loop, inserting PRINT 123 forever until it inevitably runs out of space and crashes.