3 ms·
I'm not sure what you have in mind but in the 1975 dialects of BASIC the code was something like 10 REM Grab input 20 GOSUB 1000 30 IF VALUE=BAR THEN GOT
by badsectoracula 7y ago
I'm not sure what you have in mind but in the 1975 dialects of BASIC the code was something like
10 REM Grab input
20 GOSUB 1000
30 IF VALUE=BAR THEN GOTO 100
40 IF VALUE=BAZ THEN GOTO 200
50 IF VALUE=BLA THEN GOTO 300
60 GOTO 20
100 REM Bar stuff
110 blahblah
199 RESUME
200 REM Baz stuff
210 blahblah
299 RESUME
300 REM Bla stuff
310 blahblah
399 RESUME
1000 REM Code that grabs input
1010 blahblah
1100 RESUME
Or just here is some actual BASIC game:
https://github.com/peteri/ClassicBasic/blob/master/Games/king.bas https://github.com/peteri/ClassicBasic/blob/master/Games/kin...
Note that this is a bit more readable than what people worked with since now you have syntax highlighting.
I'm not sure where tail calls enter in the picture... there wasn't even support for functions, at best you had GOSUB/RESUME which was essentially assembly-like CALL/RET.
- zozbot234 7y ago> I'm not sure where tail calls enter in the picture... GOTO essentially involves setting the continuation of your program to something other than the following instruction(s). That's what a tail call does. No "functions" involved except as a high-level description.
- stOneskull 7y agodid they use resume before return.. i had no idea. i loved how going from c64 basic to amiga basic, you didn't need line numbers anymore
- laumars 7y agoI don't think that example you've posted is right (the grab input one, not the game on Github). Firstly, RESUME was to continue execution after an error (eg ON ERROR RESUME NEXT). I think RETURN is what you might have meant? Secondly, you cannot RESUME/RETURN from a GOTO. I think you meant GOSUB; which was a crude approximation of subroutines. BASIC did also have GOTO as well though.
- badsectoracula 7y agoYes you are right, i meant GOSUB/RETURN. Though instead of "RESUME" (which should have been RETURN) most programs would use GOTO 20 (in an opposite expression of what Dijkstra wrote about, i accidentally used a 'function call' idiom instead of a spaghetti 'jump wherever' one :-P).
- int_19h 7y agoIn a world where you "call" functions with GOSUB, GOTO is an equivalent of a tail call.