Bzzzt. No.
They're not duplicate line numbers; if you were to try
those two programs /in the same machine/ (circa 1980, eg a Commodore PET) you
would find that after entering the first, the output would be:
HELLO
WORLD
and then enter the second *WITHOUT* using a NEW command, the
output would be:
HAVE A GREAT WEEKEND :)
PATRICK.
a
completely different program - using the command LIST, the output would
be:
10 PRINT "HAVE A GREAT WEEKEND :)"
20 PRINT "PATRICK."
99
END
In entering the program, the new lines 10 & 99 would replace
the original lines 10 & 99 - the line numbers are symbolic references (DOH!)
to "pigeon holes" that hold the lines of the program; if the same line number is
used, the contents of its "pigeon hole" get replaced. These symbolic references
(BHA!) can also be used as the destination of a GOTO, for example,
adding:
40 GOTO 10
would mean that the program then looped
forever, as when it reached executing that line, it would search (from the
beginning of the program) for a line with that number and then continue
execution form that point, printing out the text again, and again, and again,
and... until it was stopped somehow.
Only in more "modern" BASICS is it
where every line does not have to have a number and they are compiled (either to
machine code or a byte code which is then interpreted); in these cases, they are
more akin to the labels used in scripts, etc.
Which brings me to my
experience of three different BASICS I've used and how they store and run their
programs:
- The Acorn Atom (1980-1982)
This stored its programs
(with every line numbered) as plain ASCII with no interpretation at entry time -
it read "words" at a time and then interpreted them to find keywords to call
(machine code) subroutines for PRINT, etc which then interpreted their arguments
from the program code.
-
The Commodore PET [3000/4000 series] (circa
1980-1983)
This stored it programs (with every line numbered) by
interpreting "words" at entry time to convert keywords into a byte code which
was an offset into a jump table so that calling the (machine code) subroutines
was faster; the subroutines still interpreted their arguments from the program
code.
-
[Pick] DataBASIC (circa? programmed 1985-94)
This required
programs to be stored in a standard file/item as a plain text file which was
then compiled to a byte code; only lines which were the destination of a GOTO or
GOSUB needed to be numbered (more a "symbolic reference"). During the
compilation, the program was "rewritten" to convert expressions into reverse
polish notation; variables (dynamic arrays) were stored as an address (offset
from the base of the variable storage), destinations of GOTOs and GOSUBs stored
as an address (offset relative to start of the program); and the whole byte code
interpreted.
[ Reply to This | Parent | # ]
|