Why did bbc basic not inspire named Gosubs in other Basics?
Why did bbc basic not inspire named Gosubs in other Basics?
It seems puzzling to me that the beeb's BBC BASIC's named procedures (with parameters/local variables) did not inspire named Gosubs in its era's competing Basics (eg Cpc/ spectrum ): without the complication of parameters or locals surely a named gosub is a large improvement in readability for a small implementation outlay (and could be faster like Beeb procs)----
GOSUB screenClear is surely much nicer
Than GOSUB 401?
GOSUB screenClear is surely much nicer
Than GOSUB 401?
Re: Why did bbc basic not inspire named Gosubs in other Basics?
Without reading the minds of/asking anyone who wrote any of the other BASICs post BBC BASIC, I think you're never going to be able to answer that question.
(I also don't see any reason why anyone would use a named GOSUB in BBC BASIC, even though it was available, as you had PROC/DEFPROC)
(I also don't see any reason why anyone would use a named GOSUB in BBC BASIC, even though it was available, as you had PROC/DEFPROC)
Re: Why did bbc basic not inspire named Gosubs in other Basics?
As an aside, how would "named GOSUBs" work? I can think of two possible mechanisms:
Option 2 is rife with problems. For example, what happens if someone renumbers the program? Or if someone forgets that "screenClear" is being used as a GOSUB destination and accidentally uses it to store the result of an ordinary calculation? I know that "BASIC" and "robust" are not synonyms, but even so this looks like a recipe for disaster.
- An additional statement type (e.g. LABEL label-name) is introduced to mark the start of a subroutine. The programmer can then use "GOSUB label-name".
- The destination is held in an ordinary BASIC variable (e.g. "screenClear=401").
Option 2 is rife with problems. For example, what happens if someone renumbers the program? Or if someone forgets that "screenClear" is being used as a GOSUB destination and accidentally uses it to store the result of an ordinary calculation? I know that "BASIC" and "robust" are not synonyms, but even so this looks like a recipe for disaster.
Re: Why did bbc basic not inspire named Gosubs in other Basics?
I meant the language itself to implement it internally so I meant implemented similarly to beeb procs (so search and cache sub addresses, so it gains a speed advantage) but without the complexity of supporting parameters/arguments: thus I would expect such GOSUBS to be simple enough for a person capable of writing an interpreter.
Line renumbering is not a problem as the interpreter deals with searching for and caching the sub definition body.
One could do GOSUB .<label> with a new token for the pair to save mem/gain speed; and either a new DEFSUB keyword could be used and/or again just a preceding decimal point* before the Subroutine entry label just like assembly labels.
*or other punctuation the dec point was inspired by assembler labels.
Re: Why did bbc basic not inspire named Gosubs in other Basics?
Loads of my Spectrum Basic programs are full of stuff like:
LET CON=1000:LET COFF=1010:LET CSET=1020
....
GOSUB CON:GOSUB CSET:GOSUB COFF
...
etc.
1000 blah blah blah:RETURN
1010 blah blah blah:RETURN
1020 blah blah blah:RETURN
etc.
eg link.
LET CON=1000:LET COFF=1010:LET CSET=1020
....
GOSUB CON:GOSUB CSET:GOSUB COFF
...
etc.
1000 blah blah blah:RETURN
1010 blah blah blah:RETURN
1020 blah blah blah:RETURN
etc.
eg link.
Code: Select all
$ bbcbasic
PDP11 BBC BASIC IV Version 0.45
(C) Copyright J.G.Harston 1989,2005-2024
>_
Re: Why did bbc basic not inspire named Gosubs in other Basics?
Microsoft-style Basics generally didn't allow variables to be used in GOTO, GODUB and RESTORE statements, and some other BASICs followed this lead — Locomotive Basic in the Amstrad CPCs. The short-lived Amiga BASIC from Microsoft did have named GOSUBs etc and didn't have line numbers IIRC. Later QuickBASIC and its descendants had named subroutines and functions.
Re: Why did bbc basic not inspire named Gosubs in other Basics?
It would be nicer if it was built into the language though ....
(Also the spectrum doesnt seem to have a renumber command which suits your method)..
Re: Why did bbc basic not inspire named Gosubs in other Basics?
Spectrum (and ZX81) BASIC had exactly that feature; its GOTO and GOSUB statements (and RESTORE, on the Spectrum) would accept any expression that resolved to a number. Meaning you could do things such as GOSUB 1000+1000*INT(RND*6) if you really wanted. But it was more useful in constructions like GOSUB menu or GOTO mainloop. And unlike BBC BASIC, Sinclair BASIC would accept a non-existent line number as a GOTO or GOSUB target (carrying on from the next line afterwards). I haven't doven deeply enough into the ROM code to know for sure, but I'd guess someone was using JR C as opposed to JR Z when searching for the target line.B3_B3_B3 wrote: ↑Tue Apr 30, 2024 11:51 am It seems puzzling to me that the beeb's BBC BASIC's named procedures (with parameters/local variables) did not inspire named Gosubs in its era's competing Basics (eg Cpc/ spectrum ): without the complication of parameters or locals surely a named gosub is a large improvement in readability for a small implementation outlay (and could be faster like Beeb procs)----
GOSUB screenClear is surely much nicer
Than GOSUB 401?
Re: Why did bbc basic not inspire named Gosubs in other Basics?
The above tricks would be scuppered by a renumber command?julie_m wrote: ↑Tue Apr 30, 2024 4:04 pm....
Spectrum (and ZX81) BASIC had exactly that feature; its GOTO and GOSUB statements (and RESTORE, on the Spectrum) would accept any expression that resolved to a number. Meaning you could do things such as GOSUB 1000+1000*INT(RND*6) if you really wanted. But it was more useful in constructions like GOSUB menu]. ...
I had hoped my original post was clear that I meant the Renumber-proof bbc procedure/function name style of storing the name against an address in a list which is also faster after eachs' 1st call (unless some preprocessing is done but that is a separate post )
Re: Why did bbc basic not inspire named Gosubs in other Basics?
No renumber command in spectrum/ZX81 BASIC.B3_B3_B3 wrote: ↑Tue Apr 30, 2024 4:27 pm The above tricks would be scuppered by a renumber command?
I had hoped my original post was clear that I meant the Renumber-proof bbc procedure/function name style of storing the name against an address in a list which is also faster after eachs' 1st call (unless some preprocessing is done but that is a separate post )
- 1024MAK
- Posts: 12807
- Joined: Mon Apr 18, 2011 5:46 pm
- Location: Looking forward to summer in Somerset, UK...
- Contact:
Re: Why did bbc basic not inspire named Gosubs in other Basics?
For the ZX Spectrum, there was no renumber command until the introduction of the 128 model.
What you are really asking is why manufacturers of machines using BASIC did not include labels as an option in the code. Then GOTO label or GOSUB label would have been possible.
Psion did include labels in their BASIC like OPL.
I suspect the main reason was a combination of wanting the provided BASIC to be to the minimum of what was then recognised as "standard" BASIC, cost and available ROM space. With other "more exciting" features taking priority (graphic and sound commands/functions as some examples).
Mark
What you are really asking is why manufacturers of machines using BASIC did not include labels as an option in the code. Then GOTO label or GOSUB label would have been possible.
Psion did include labels in their BASIC like OPL.
I suspect the main reason was a combination of wanting the provided BASIC to be to the minimum of what was then recognised as "standard" BASIC, cost and available ROM space. With other "more exciting" features taking priority (graphic and sound commands/functions as some examples).
Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki - for answers to many questions...
Fault finding index • Acorn BBC Model B minimal configuration • Logic Levels for 5V TTL Systems
BeebWiki - for answers to many questions...
Fault finding index • Acorn BBC Model B minimal configuration • Logic Levels for 5V TTL Systems
Re: Why did bbc basic not inspire named Gosubs in other Basics?
The Atom Basic has labels for GOTO and GOSUB, albeit a single letter
This is quite fast because the address of the label is stored at a fixed position in the Basic workspace memory. So the interpreter doesn't need to search for a line number every time a GOSUB or GOTO is used. Line numbers are still allowed.
Code: Select all
10 GOSUB c
20 PRINT "TEXT ON AN EMPTY SCREEN"'
30 END
40
50cPRINT $12
60 RETURN
FPGAtom: 512 KB RAM, Real Time Clock and 64 colours
MAN WOMAN
MAN WOMAN