Dave McGuire wrote:
On Apr 23, 2008, at 12:04 AM, Jim Battle wrote:
...
What is cool
about the BASIC? Long variable names, proper subroutines
with local variables, good extensability. There is a lot more, but I
don't have the manual at hand to refresh my memory.
Subroutine-local variables in a BASIC interpreter?? Wow, that's
something I'll need to try. That's cool.
I recall reading through the manual a bit and inferring something about
the interpreter's structure.
Like most BASICs, it is tokenized in memory. Variables aren't stored as
literals, unlike MS basic. Instead, there is a byte token meaning: a
variable, and the next byte is an index into the symbol table. Thus a
given program can have no more than 254 unique variable names, or
something like that. With a 8K computer, that seems unlikely to be a
problem. The symbol table has the variable name, attributes, and value.
Thus if you have something like
10 THISREALLYLONGVARIABLENAME = 1
20 THISREALLYLONGVARIABLENAME = THISREALLYLONGVARIABLENAME + 1
the name is stored only in the symbol table, so there is very little
penalty for long names. Accessing vars can be done quickly too,
potentially just a double index, but perhaps it is not implemented that way.
The down side is that if you enter this line:
30 FRISTAJAMTHINGAMABOB = 3.14
and then change the line
30 FOO = 3.14
the FRISTAJAMTHINGAMABOB var is still in the symbol table, even though
nothing references it. There is a command that cleans up dead vars in
the symbol table.
It has been too long to recall the details, but there is something about
attaching and detaching subroutines that seemed interesting. It wasn't
a matter of threading, it had something to do with scoping, but I forget
now. It seemed interesting.
Another fun thing is that the FP format is decimal, but it doesn't use
BCD. It uses base-100 digits, one digit per byte. It saves a lot of
nibble level mucking around, but it does hurt a bit in that the mantissa
are effectively normalized by pairs of digits, instead of a single digit.
I don't recall if the CC-40 has it, but the TI-74 has a debug mode that
can be entered, such that you can access register state, change the PC,
inspect memory, set a breakpoint, etc.
If you like quirky BASIC's, check out Wang BASIC and BASIC-2. It starts
with the classic Dartmouth basic, including MAT statements, but then
adds on a lot of Wang's own syntax.
Here was my attempt at a comparison between MS BASIC (say, the kind
found on TRS-80 Level 2 BASIC), and Wang BASIC. BASIC-2 enhances BASIC
in many ways, including adding the ELSE clause and allowing conditional
conjunctions, but I didn't get into that.
http://www.wang2200.org/basic_comparison.html
Wang BASIC itself evolved over time before BASIC-2 came out. Here is my
terse summary of that:
http://www.wang2200.org/versions.html
Here are some examples of the crazy syntax that Wang had for searching
and sorting array data. It is an extension of the MAT command syntax:
MAT CONVERT A() TO A$()(6,8)
MAT COPY A$() <X*Y, 100/X> TO -A$()<10,20>
MAT MERGE A$ TO W1$(), W2$(), S$()
MAT MOVE A$(), L$(2,3), M TO B$(1,1)
MAT MOVE A(), L$(1) TO A1(1)
MAT SEARCH A$()<1,5>,=STR(Z$,1,5) TO B$ STEP 5
MAT SORT A$() TO W$(), L$()
Want to convert a number to a string with formatting? Here it is:
10 CONVERT A TO A$,(+#.#####^^^^)
Want to fill a string with a character?
INIT("x") A$
Want to rotate each byte of a string left three bits?
ROTATE(A$,3)
Want to translate an array of strings from EBCDIC to ASCII? The $TRAN
statement will do that (or any other byte mapping).
On the other hand, they kept some of the worst features of Dartmouth
BASIC: variables are all either a single letter, or a letter and a
digit. There are no local variables, except for the "10 DEFFNA(x) =
SQR(x)/3" type of statement. Strings are statically allocated, and can
be at most 64 characters long (in BASIC; BASIC-2 allows 124 bytes per
string).