Rich Talbot-Watkins wrote: ↑
Thu Jun 13, 2019 1:51 pm
they could have had two tables of execution addresses for tokens - one for statements and one for expression elements - and overlapped the index range.
So is there a single dispatch table (for both functions and statements) in 6502 BASIC? That would 'explain' it, but it never occurred to me to do that in my interpreters (they have two tables) and I can only see disadvantages in doing so. Sophie's judgement can usually be relied on (although I know of exceptions!) so perhaps there's something I'm missing.
I've wondered the same thing about the extra tokens, particularly since Sophie already used &7F for OTHERWISE.
Once you've committed to using &7F you have to use an unsigned comparison (for the range 127 to 255) rather than the signed comparison needed for -128 to +31. So that seems a particularly strange choice because it gains one token at the expense of 30!
Why are immediate mode only commands a 'thing'? Why is it any kind of big deal to write LIST or NEW or SAVE in a program?
Those commands may not be consistent with continuing program execution afterwards (maybe they use, and thus corrupt, some critical memory area) so they would probably need to exit to immediate mode - that's obviously true of NEW. Perhaps there was concern about providing a way to exit to immediate mode without going via the cleanup provided by END. But that's not a very convincing explanation.
Why did Acorn/BBC think that COUNT was a worthwhile keyword, being both non-standard and of very limited use in my opinion?
COUNT is used internally by the PRINT statement, it determines what TAB(n) does. I can see an argument for making it available in case you want to write a replacement for PRINT with a similar capability.
Likewise WIDTH. I don't think I ever used either of them!
I have made use of WIDTH when outputting to a printer or a file, when you haven't got the automatic text 'wrapping' at the edge of the text viewport.
The special line number encoding (token &8D) was used I guess so that RENUMBER didn't alter line lengths.
I don't think it is so much to do with line lengths, but to make it easier for RENUMBER to scan the program for the &8D token than to parse every line for a (ON) GOTO, (ON) GOSUB or RESTORE followed by a numeric constant (or list thereof).
could this encoding have been used as an optimisation for any integer literal within the allowed range in a program, to improve performance?
Some BASICs (QBASIC for example) do encode numeric constants to improve performance. I've often wondered why BBC BASIC doesn't, but if it did I think it would need to use a separate 'token' from that used to flag line numbers (again so RENUMBER can simply scan for the destinations it may need to change). As an aside, BB4W and BBCSDL have a mechanism for replacing variables, arrays and PROC/FN references by a binary encoding (to avoid the name lookup process) but not constants.