Even more simple.
Just add different label for subroutines, say, subroutines should start with SUB statement, after the label. At compile time, do check and that's all.
Even more simple.
Just add different label for subroutines, say, subroutines should start with SUB statement, after the label. At compile time, do check and that's all.
Then 80% of my programs wouldn't compile. I often use multiple entry point in same sub. And have only one return at end.
Or the reverse. Have one entry and multiple exits:
IoannisCode:gosub test .... test: if x=1 then a=1 return endif if x=2 then a=2 return endif return
So you're doing it wrong - same for overlapping for-next cycles![]()
If you mean my example, OK, it is a not efficient one but I was trying to show that you can have many Returns from the same sub.
Sure it can be made more compact or efficient, but still. Compiler has difficult time to check this for errors.
Ioannis
Ok, here is an example (not exact syntax, just to get idea)
In above example, if we remove RETURN, it will compile fine in PBP, but will produce unusable code. But even on ZX Spectrum, it would give us "Gosub without return" error, and save our time.Code:MAINCODE: 'do something high PORTC.0 PAUSE 500 low PORTC.0 Pause 500 GOSUB CHECKER GOTO MAINCODE CHECKER: TOGGLE PORTD.0 RETURN
Agreed. This is easy to check, but above we stated other cases that are difficult to check.
So a sub-without-return check in whole is not easy to implement. I suppose... Maybe Charles knows better to justify it.
Ioannis
Bookmarks