On 8/28/2020 at 7:58 PM, SerErris said:
I agree, I do not see any reason for else.
You do not need to do anything it works out of the box like that:
So we even have a ELSE with multiple lines already in it. Yes it is a little bit different to write but it is not an issue and easy to understand after you worked with it.
Really, all Control Structures except counted loops are semantic sugar for GOTO and IF <condition> THEN GOTO. Where ELSE is needed is not in the ROM Basic, but as a reserved and reusable structured label in the EditorBasic, which allows working with labels and the editor basic sorts out line number behind the scenes.
TASK5: IF X5>0
THEN: DOTHIS
DOMORE
DOMORE
ELSE: DOTHAT
DOMORE
DOMORE
ENDIF
Becomes:
450 IF X5>0 THEN GOTO 460
455 GOTO 490
460 DOTHIS :
470 DOMORE
480 DOMORE:GOTO 520
490 DOTHAT
500 DOMORE
510 DOMORE
520 ...
Commodore 128 Basic V7 ELSE is just a modest space saver:
450 IF X>0 THEN GOTO 460:ELSE GOTO 490
460 DOTHIS
470 DOMORE
480 DOMORE:GOTO 520
490 DOTHAT
500 DOMORE
510 DOMORE
520 ...
But I am confident that all of the classic structured program structures can be done with IF/THEN and GOTO, because I am in the middle of implementing a Forth ... and while Forth has all of the classic structured programming structures, the underlying primitives are just BRANCH and ?BRANCH. IF/THEN/ELSE/ENDIF, REPEAT/UNTIL and BEGIN/WHILE/AGAIN are all straightforward to implement with GOTO and IF/THEN alone.
However, unless ELSE is implemented for speed, with the content after the ELSE token linked into the line number list, then the second is slower than the first, but I presume that the actual V7 implementation does it the slow way.