From: Michael W. <mfw...@MI...> - 2008-02-17 05:55:04
|
I wrote the following earlier: (http://sourceforge.net/tracker/index.php?func=detail &aid=1894717&group_id=149850&atid=775999) > I agree that standardization is essential. It should > be something very simple. > > (1) With all spaces, a great deal of control > over the formatting is possible. > > (2) Tabs take up less space and are usually > the default (width 8) in most editors. I > would suggest: All leading whitespace on > a line should be tabs; most or all white- > space after non-white space characters > should be spaces. > > The number one rule should be: Write stuff that will > look consistent in all editors. However, that was an uncharacteristic outburst of enthusiasm for tabs, which I've tried to use of recent. However, I've [re]convinced myself that spaces alone are the way to go, because they offer absolute formatting that is guaranteed to be the same in every editor; it should be simple to provide a script that warns people of mixed tabs and spaces. It is my belief that formatting plays an integral role in the readability, maintainability, and understanding of code, so absolute control is therefore essential. For instance, the alignment of the backslashes in the following code is only guaranteed to be correct when nothing but spaces is used for leading and trailing whitespace: #define YY_INPUT(buf,result,max_size) do { \ if (istack->file) { \ size_t rc = fread(buf, 1, max_size, istack->file); \ result = (rc == 0) ? YY_NULL : rc; \ } else { \ if (*istack->str == 0) \ result = YY_NULL; \ else { \ buf[0] = *istack->str++; \ result = 1; \ } \ } \ } while (0) Moreover, the code is presented as intended by the author. Sincerely, Michael Witten P.S. I would like to add that I don't believe code should be written as though it's meant to be printed; that is, code should not be hard wrapped unless absolutely necessary. |