9

These days, most compilers and interpreters seem to provide the following in diagnostics:

  • A description of the problem
  • The name of the source file
  • A line number
  • A relevant position within the line
  • The text of the line
  • An indication of where the relevant position is in the line's text

In earlier systems, diagnostic printouts often consisted, from what I can tell, of a message or error code and the text of an offending card or line. All that is really missing is the precise indication of where on the card or line the problem was found.

I was somewhat surprised to see that the Pascal P-series of compilers, as far back as P2 from 1974, provided almost everything that modern systems do:

  • An error code
  • A line number
  • The text of the line (albeit as a side effect of listing the source code)
  • An indication of where the relevant position is in the line's text

(See the routines error and endofline. The file name was implicit, since only one file was ever being compiled.)

Did any systems predating P2 do this (or better, e.g. by indicating a range of positions as in GCC and Clang)? LISP 1.5 seems to have been close, having a function error1 that was designed for this exact purpose (printing a line of text along with a “cursor”), although the interpreter never actually used it!

6
  • 3
    It might be worth to keep in mind that a good error description is usually way more helpful. This is especially true with classic languages like Assembler, COBOL or FORTRAN, were each line was always a single statement. Only free form languages (essentially all ALGOL descendants) gain from having a column noted, as a line could have more than one statement, making assignment of a specific message to each hard.
    – Raffzahn
    May 30 at 1:48
  • 2
    For a contrary opinion: SNOBOL4 was a one statement per line (card-oriented) language, and its authors found it useful to indicate the offending column (by mean of a mark in the appropriate place under the listed source line). See page 175 in the linked document. Of course, some people might consider SNOBOL4 to be more-or-less syntax-free :-) May 30 at 2:17
  • 2
    @Raffzahn "Only free form languages gain from having a column noted" Not when a single-line Fortran statement contained 10 pairs of parentheses - or rather, it should have contain them, but didn't.
    – alephzero
    May 30 at 12:28
  • @alephzero True, but only (somewhat) useful if they are non nested pairs in 10 different expressions. As soon as they share the same expression, the compiler might only point at the end of that whole expression - not really useful, or is it?
    – Raffzahn
    May 30 at 13:15
  • @Raffzahn: COBOL formally allows multiple statements on one line with a few exclusions, although given the verbose style it encourages and sometimes requires, relatively few pairs of complete statements fit in the 61 chars traditionally available in Area B (this is now increased). And if/when you couldn't do it in most cases, people often like(d) to be consistent and never do it. Jun 28 at 9:49
12

Printing a mere column number seems like a step backwards. The Whetstone Algol compiler (1963, if memory serves) told you the line number and delimiter that were problematic, as well as (of course) an error code and the line in question.

FAIL 133
LINE   6    
DELIMITER [̲
IDENTIFIER writetex
BECAUSE OF LINE   2

Underlined bracket, shown as 2 separate characters on modern ASCII equipment but not on the contemporaneous Flexowriter, was a string quote in this Algol dialect.

Error 133 means we ran off the end of the program text at line 6, in this case because of a missing closing string quote. The opening string quote was on line 2, just after the identifier writetext (this dialect considered only 8 characters to be significant).

So, my answer to the question is another question – didn't they always do this? (Depends on implementation, of course, and how much attention was paid to diagnostics. The Walgol guys were pretty keen on diagnosability).


KDF9 was oriented to paper tape rather than cards, and paper tape people don't really think in terms of column numbers, so a raw column number wouldn't have really helped anyway. On the other hand, converting "column N" to N−1 spaces and an up-arrow on the listing, underneath the listing of the offending line, is decidedly better.

SNOBOL4, developed in the early 1960s at Bell Labs, initially on IBM System/360, used that particular technique.

Section 10.1.5 in The SNOBOL4 programming language, the definitive description of SNOBOL4, shows that the error indicator was a (vertical) apostrophe. Likely that particular listing was from SNOBOL on an S/360.

X = A+B
    '  
*** ILLEGAL CHARACTER IN EXPRESSION

(Operators needed to be offset by spaces or other delimiters)

At the time SNOBOL4 was developed, it was very much a card-oriented language, though it had no particular column requirements except for column 1 having special meaning (labels and comments), and of course a 72-columm limit.

This example shows that error-location to a column was already a known technique in the 1960s, though of course this is the 'pointer in column' approach rather than 'print column N' approach.


(I removed the FORTRAN example, since although it demonstrated a good level of error diagnosis, it's not really relevant to the point of location by specific column).

11
  • 1
    Well, I guess like so many, it's a solution which, like any other needs a problem to be useful. With languages like Assembler, FORTRAN or COBOL, it's way more useful (like shown in the second example) to give a fine worded description.
    – Raffzahn
    May 30 at 1:55
  • 1
    @Raffzahn - I updated my answer: printing "column N" is not so useful, but using that to place an uparrow on the listing is much more so. May 30 at 2:00
  • This answer brings up some interesting points I hadn't thought of. The Walgol example reminds me of Perl's error handling for multi-line strings. Here is how GCC reports a similar error in a C program: godbolt.org/z/W4jecv6Wb.
    – texdr.aft
    May 30 at 4:36
  • 2
    @another-dave To be fair, with the source code on punched cards, "column N" was as good as an uparrow. Finding "N" among the column numbers between rows 0 and 1 on the card and looking up to the printed text: en.wikipedia.org/wiki/Punched_card#/media/… is easy.
    – Leo B.
    May 30 at 7:31
  • @LeoB - maybe, but for understanding the error, seeing clear indication on the line printer listing is better. Isn't the existence of listings evidence that it's easier than reading the cards? (I agree that ultimately I have to find the erroneous card to replace it). May 30 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.