Too many GOTO statements

by E W Dijkstra (no login)

grep "goto [a-zA-Z_]*;" libqbx.cpp qbx.cpp | wc -l
661

This is just counting the GOTOs in the C++ source; there's probably more in the BASIC source, but we don't know how many because QB64 is closed source.

However, the number of GOTOs can be estimated by calculating the percentage of BASIC statements that are GOTOs over a large sample, such as the QB64 samples collection.

find . -name '*.bas' | xargs cat | wc -l
54740

find . -name '*.bas' | xargs grep -i goto | wc -l
2034

2034 GOTO lines / 54740 total lines of code
means that 3.72% of BASIC statements are GOTOs.

According to http://www.qb64.net/forum/index.php?topic=149.msg407#msg407,

the QB64 source code was 12869 lines long in December 2008.

From this, we can calculate that there are about 478 GOTO statements in the QB64 BASIC source. (Using the statistics for the C++ code to perform the calculations for the number of GOTOs in the BASIC code yields similar results).

See also:
"A case against the GOTO statement"
http://www.cs.utexas.edu/~EWD/transcriptions/EWD02xx/EWD215.html



Posted on Jul 5, 2009, 9:30 AM

Respond to this message   

Return to Index


Response TitleAuthor and Date
GOTO hell on Jul 5
I don't need a lecture about the GOTO statement... on Jul 5
 *Being in the wrong forum is the least of Dijkstra's problems. He's dead, after all. on Jul 14
GOTO for JavascriptAnonymous on Jul 6