4 ms·
Very well put. I remember writing gotos everywhere when I learnt to code. Interestingly enough my first program was almost the same as yours. Great thing about
by yoz-y 9y ago
Very well put. I remember writing gotos everywhere when I learnt to code. Interestingly enough my first program was almost the same as yours. Great thing about a goto is that it is a single command which can emulate any of the other constructs.
Also one thing I remember from back when was that if there was a problem I did not understand (I was mostly learning by modifying example programs that I somehow got) the only way to solve them was to try more things and harder. I did not have any books and internet was a luxury. Eventually I have understood more of the code and got better.
Nowadays it is way easier to remain ignorant and still be productive.
- laumars 9y ago> Great thing about a goto is that it is a single command which can emulate any of the other constructs. The thing is BASIC does have other constructs. GOSUB[0] has been around in the 70s and that worked like a GOTO except when a RETURN statement was hit the code would then jump back to the point where it GOSUB'ed - effectively behaving as a rudimentary subroutine (hence the name, "GoSub"). There was also the FN[2][3] statement that allowed you to write basic functions, albeit you were limited to 1 liners. But by the 80s some dialects of BASIC were supporting more complex procedures[3][4]. [0] http://www.hoist-point.com/applesoft_basic_tutorial.htm#string_functions_gosub http://www.hoist-point.com/applesoft_basic_tutorial.htm#stri... [1] http://www.cpcwiki.eu/index.php/Locomotive_BASIC#FN http://www.cpcwiki.eu/index.php/Locomotive_BASIC#FN [2] https://www.c64-wiki.com/wiki/FN https://www.c64-wiki.com/wiki/FN [3] http://www.bbcbasic.co.uk/bbcwin/tutorial/chapter16.html http://www.bbcbasic.co.uk/bbcwin/tutorial/chapter16.html [4] http://www.bbcbasic.co.uk/bbcwin/tutorial/chapter17.html http://www.bbcbasic.co.uk/bbcwin/tutorial/chapter17.html
- int_19h 9y agoAlso, didn't the FOR..NEXT loop show up really early on?
- cicero 9y agoIt was in Integer BASIC and Applesoft BASIC on the Apple II. You could say something like this to count to 10: 10 FOR I=1 TO 10 20 PRINT I 30 NEXT I
- laumars 9y agoYup. Also WHILE/WEND loops and some basic error control with ERROR (raise), ON ERROR (capture). BASIC certainly had it's faults but it was a reasonably complete language. However it can't have helped the number of different dialects there were in the 70s and 80s. Each brand of consumer electronics seemed to ship with a subtly different list of statements which meant I think lead people to often stick with the core basics of, erm, BASIC.
- int_19h 9y agoPretty sure WHILE/WEND was a slightly later addition. I just went and looked up Dartmouth BASIC (this is the original thing). The list of keywords shows FOR, but not WHILE. This is the manual for v2, as early as I could find (1964) - it also has FOR already, but not WHILE: http://www.bitsavers.org/pdf/dartmouth/BASIC_Oct64.pdf http://www.bitsavers.org/pdf/dartmouth/BASIC_Oct64.pdf (Side note: it's kinda amusing that the document uses a slash-through to distinguish the letter O from zero, except it does it in a way that is reverse of what is common today: it's the letter that has a slash through it!) I do wonder if it was a true loop, though, or whether it was implemented more along the lines of GOSUB/RETURN (i.e. whether FOR basically set up a dynamic label, and NEXT did an indirect jump). If so, then it should be possible to have two FOR statements with the same variable, both "matched" to a single NEXT, if GOTO is used to reach it from one of the loops.
- laumars 9y agoAhh sorry, I was talking in the context of the microcomputer era of the late 70s and 80s rather than the full history of BASIC. Thanks for the PDF, that will make really interesting lunch time reading :) > I do wonder if it was a true loop, though, or whether it was implemented more along the lines of GOSUB/RETURN (i.e. whether FOR basically set up a dynamic label, and NEXT did an indirect jump). If so, then it should be possible to have two FOR statements with the same variable, both "matched" to a single NEXT, if GOTO is used to reach it from one of the loops. I could be wrong here but I think most high level structures (switch, for loop, etc) end up getting translated to GOTOs at the machine level anyway. So you might be right with regards to the BASIC interpreter. As for whether you could have fun with that, Dartmouth is before my time but I remember Locomotive BASIC (Amstrad CPC 464, so we're talking early 80s) used to do run time checks to ensure you weren't abusing NEXT inside nested FORs.