Possible Duplicate:
Why did we bother with line numbers at all?
I'm curious about why early versions of the BASIC programming language had line numbering like in:
42 PRINT "Hello world!"
The text editors back then had no line numbering?
EDIT: Yes, I know they are used for GOTOs, but why? I mean having labels was too computationally expensive?
The purpose of line numbers was for branching and for reference by formatting statements. Both JOSS and BASIC made line numbers a required element of syntax.
Line numbers also give the developer a quantifiable sense of how long his code is and, in the case of large files, a sense of where in the file he is. Not to mention, line numbers are absolutely essential when doing any sort of partner programming.
Many microcomputers had a BASIC interpreter in ROM that would start upon bootup. The problem was that there was no text editor or file system to speak of. You had an interactive prompt to do everything through. If you wanted to insert a line of code, you just typed it, starting with the line number. It would insert it into the correct spot in you code. e.g:
>10 print "hello" >30 goto 10 >20 print "world" >list 10 PRINT "hello" 20 PRINT "world" 30 GOTO 10 >
(In that example > is the BASIC prompt)
If you wanted to erase a line, you would type something like ERASE 20
.
Some really fancy systems gave you a line editor (i.e. EDIT 10
)
And if you didn't plan your line numbers and ran out (how do I insert a line between 10 and 11?) some systems gave you a RENUM
command which would renumber your code (and adjust GOTOs
and GOSUBs
appropriately).
Fun Times!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With