On 2/22/2021 at 2:30 AM, TomXP411 said:
You didn’t read the full document, did you? There are three different loop structures, and all are taken straight from BBC BASIC.
No, I didn't. WHILE/WEND and REPEAT/UNTIL loops are less flexible than CBM/QBasic Basic DO LOOP, and even there GOTO is stll needed for some loop structures. Making the tests orthogonal to the loop fixes that issue.
BEGIN-BLOCK operation test operation END-BLOCK is the most generic loop structure, since it intrinsically provides:
BEGIN-BLOCK test operation END-BLOCK
BEGIN-BLOCK operation test END-BLOCK
... as the QBASIC DO [UNTIL/WHILE] ... LOOP [UNTIL/WHILE] loops do, and if done correctly, it can also provide:
BEGIN-BLOCK operation1 test1 operation2 test2 operation3 END-BLOCK
... which is handy for a range of string processing loops ... test for condition, and test for end of string.
The optimization referred to is that in the interpreter version, LOOP keywords can be chained together, (token $priorloopaddress) typically making finding the first loop following a failing test substantially faster than a BASIC GOTO that searches sequentially for the line. DO / LOOP can use the FOR/NEXT stack, by relying on an impossible variable reference address, such as $0000.