3 ms·
In the mature versions of BASIC, SUB was for routines that didn't return any value and FUNCTION was for returning a value. I'd 100% skip the line numbers and G
by ChicagoDave 4y ago
In the mature versions of BASIC, SUB was for routines that didn't return any value and FUNCTION was for returning a value.
I'd 100% skip the line numbers and GOTO/GOSUB and build those two things. I grew up PDP BASIC and then VAX BASIC and the procedural aspect is what made it a great platform to write code. the line number/GOTO stuff is great for nostalgia, but a dead end for good coding practices.
- TedDoesntTalk 4y agoThis is a great idea. I grew up with AppleBASIC, which had line numbers, but after decades coding with many other languages, there’s no reason to use line numbers. And if the purpose of this repl is to teach, then teaching line number programming in 2022 is pointless. Unfortunately it then requires an editor, otherwise how do you overwrite/change a line?
- dragonwriter 4y agoTo me the main use of line numbers is that they allow you to have a seemless combination of an immediate environment and a line-oriented program editor. With modern UI, there's pretty much no reason to do that, of course; with a retro style UI, there might be some marginal use. (Also, supporting line numbers and line-oriented GOTO/GOSUB means you can directly use any of the libraries or classic code in that style; unwinding GOSUB/RETURN into named subs is trivial enough if it is otherwise clean, but unwinding GOTO-heavy code without having a working starting point isn't pleasant.)
- 7thaccount 4y agoIsn't saying "GOTO 40", where 40 is the line number a big deal with old-school BASIC? Something along those lines anyway?
- bhauer 4y agoAgreed. I'm not familiar with PDP or VAX Basic, but I did grow up on GFA Basic with its PROCEDURE and FUNCTION. Both could be called by just using their name without a GOSUB. PROCEDURE printfoo(bar%) PRINT "foo: " + bar% RETURN FUNCTION double(number%) RETURN number% * 2 ENDFUNC ' Prints "foo: 8" printfoo(double(4))
- ChicagoDave 4y agoMicrosoft Professional Development System 7.1 and later Visual Basic for DOS 1.0 had similar language syntax. I had put together a DOSBox VM with PDs installed awhile back. Still have it if you're interested. I built software using PDS professionally back in 1990.
- ChicagoDave 4y agoThe better choice is to fire up MS DOS 3.1 on VirtualBox and download VB for DOS 1.0 and install it (7 floppy images). Takes a but, but it's a solid BASIC syntax and it's the successor to PDS 7.1. To get PDP or VAX BASIC running, you'd need to emulate a PDP with RSTS/E or VAX+VMS and BASIC is built in. There are Raspberry PI images for both. Personally I think SUB ... END SUB and FUNCTION ... END FUNCTION are the clearest syntax.