Newsgroups: | comp.compilers |
From: | cg@Myrias.AB.CA |
Keywords: | design |
Organization: | Myrias Computer Technologies |
References: | 95-04-013 95-04-147 |
Date: | Thu, 27 Apr 1995 14:57:56 GMT |
Charles Fiterman <cef@geodesic.com> writes:
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.
The former may be easier on the eye, but I see some problems with
trying to do that, especially in C (or C++ as in the example). First,
I could no longer use the convention of putting temporary (e.g.
debugging prints) code at column 1 in the middle of normally indented
stuff. I would have to have some other convention, such as an added
comment, for finding such things. The non-indented stuff is very easy
to see.
I had initially thought that multi-line macros would be a problem, but
since they are actually only one logical line, I think they would be OK.
I personally go out of my way to avoid lines that don't fit in a standard
80-column window, so I sometimes outdent long strings constants. This
would be messed up, too.
Long expressions in general become more of a problem. Artificial rules
such as requiring extra parentheses in them are destined to cause
problems for users, automatic pretty-printers, etc.
--
Chris Gray cg@myrias.ab.ca [C macros - a powerful way to make bugs!]
Myrias Computer Technologies Inc. (403) 463-1337
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.