<HISTORICAL_COMMENT>
Which is dumb, because since in AppleSoft BASIC the highest line number is
63999 (why?), they could have easily used a reserved values to represent a
GOTO to a variable. Instead, they stored the line number as ASCII, which
is ultimately lame because a) it takes up more space, b) it requires more
time to parse and process during runtime and c) is wholly inefficient.
</HISTORICAL_COMMENT>
Well, this is true, but I think it's simply a trade-off, since apparently
runtime performance was less important than the space the darned thing took
up in ROM. The tokenizer just dumbly recognizes strings in its table. This
saves a lot of space. If the tokenizer had to know what possible
arguments/parameters were valid for each possible command, so it could
tokenize those, it would be much larger. And, the runtime parsing wouldn't
get proportionately smaller or simpler in exchange: it would still need to
recognize a sequence of argument/parameter tokens in memory; they're just
shorter, but they're not much less work to deal with.
Frankly, if I wanted to point to a bad implementation choice, the first
thing I'd pick on is the search-from-start-of-program for any line that is a
target of a GOTO or GOSUB. A simple check to see if the target line number
is greater than the current line number would facilitate a search forward
from the current location rather than the beginning of
program storage, and
could result in some hefty savings, particularly for a GOSUB in
a FOR..NEXT
loop. My style at the time was to put subroutines all at the end... bad
choice for the Applesoft interpreter, I can see.
From the comments, it appears that 63999 is the highest
line number simply
to make the parser's overflow check dead simple. As the
number is being
parsed into the accumulator, the accumulator is multiplied by 10 and the new
digit added to the result, as expected. If the accumulator value before
multiply is 6400 or more, however, an overflow is likely. They could have
chosen to test against 6552 and gotten the same simplicity with almost full
line-number room. Must have gotten a visit from the Arbitrary Fairy.
Patrick