Newsgroups: | comp.compilers |
From: | Charles Fiterman <cef@geodesic.com> |
Keywords: | syntax |
Organization: | Geodesic Systems |
References: | 95-04-013 95-04-107 |
Date: | Wed, 19 Apr 1995 13:22:11 GMT |
Semicolons are not only just a habit, they are a very bad habit.
In one study a large amount of C code was scanned for lines without
semicolons. It excluded things like fun_call(a,
b);
To look only for expressions on more than one line. It seems that
about a fourth of the lines found were errors. The missing semicolon
was simply wrong about one fourth of the time. Clearly C would be
better off with no semicolon and with a rule allowing continued lines.
Perhaps new line ends a statement except within an open (), or [].
Further I find {} silly. Everyone in their right mind indents. Count
indentation from the leftmost character of the previous line. Either
eliminate tabs as valid within programs or give them some standard
meaning like a tab takes you to the nearest 4's boundary. I would
prefer eliminating from the language, this doesn't mean editors
couldn't use tab as a command to put in spaces.
This means we could write
if x < y
cout << "hello world\n"
cin >> i
Instead of
if (x < y) {
cout << "hello world\n";
cin >> i;
}
The former is obviously a lot cleaner and eliminates a lot of style
disputes. Further it eliminates the common error where {} are
forgotten and the user forgets that indentation is not syntax.
Lines and indentation are the most obvious parts of code, the
compiler should see them too.
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.