Line number

From Free net encyclopedia

In computing, a line number is a way of specifying a point in a file by enumerating each line in the file by a number. Line numbers are used for several purposes.

In programming, if a programmer introduces a compile-time detectable bug into the program, and attempts to compile it, the compiler will often inform the programmer that the attempt to compile failed at the given line number. The line that the compiler reported often contains the error.

In older styles of unstructured programming, line numbers were used to demarcate specific code points where execution was supposed to branch to - in essence, goto commands. For example

10 IF X = 10 GOTO 40
20 X = X + 1
30 GOTO 10
40 PRINT "X is finally 10"

However, improper use of gotos often led to so-called spaghetti code. Line numbers are now seldom used for this purpose, and even languages which previously allowed branching in this manner now use text labels for program flow control.Template:Compu-soft-stub

ja:行番号