6 ms·
Yup. 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 complet
by laumars 9y ago
Yup. 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.
- int_19h 9y agoI tried it on QBASIC and Turbo BASIC, and both require matching FOR and NEXT. Now I'm really tempted to set up a Dartmouth emulator to see if it was also true there...