Admittedly it's probably mostly in traditional BASICs (which require line numbers) that I've seen this. Take these examples (cribbed from Wikipedia):
10 PRINT "Hello, World!"
20 END
and
10 INPUT "What is your name: "; U$
20 PRINT "Hello "; U$
30 INPUT "How many stars do you want: "; N
40 S$ = ""
50 FOR I = 1 TO N
60 S$ = S$ + "*"
70 NEXT I
80 PRINT S$
90 INPUT "Do you want more stars? "; A$
100 IF LEN(A$) = 0 THEN GOTO 90
110 A$ = LEFT$(A$, 1)
120 IF A$ = "Y" OR A$ = "y" THEN GOTO 30
130 PRINT "Goodbye "; U$
140 END
In each of these examples, the END
isn't doing anything, since the program will halt anyway as a result of reaching the end of the code. Neither is there a GOTO
statement or anything referencing the line. In C and similar languages, I don't recall ever seeing return;
immediately before the closing brace of a function, or exit(0);
immediately before the closing brace of main
.
What is the origin of this habit? Have there been some BASIC dialects that require it? Or have some been taught that it's a good practice for whatever reason?