On Dec 1, 2006, at 4:11 PM, Robyn Allsman wrote:

The "LSST C++ Programming Style Guidelines"  has been installed into
docushare as Document-2819.

It is currently a virtual copy of the CARMA C++ Coding Standards; it will be refined over the next week to reflect the LSST Data Management C++ Coding Standards.

Recommendation 5-13:
5-13. Variables should be declared in the smallest scope possible.

conflicts with 5-14:
5-14. Only loop control statements must be included in the for() construction.

5-14 prevents one from limiting the scope of "sum" (not a loop control variable) with this construct:

     for (int i = 0, int sum = 0; i < 100; i++)              

Also, I find their code example:

for (i = 0; i < 100; i++)
  sum += value[i];

to be dangerous. One should always use curly braces to delimit code blocks, even if they contain one statement:

for (i = 0; i < 100; i++)
{
  sum += value[i];
}

It improves readability. I've been burned more than once by the other construct.

Jon
_______________________________________________
LSST-data mailing list
[email protected]
http://www.lsstmail.org/mailman/listinfo/lsst-data

Reply via email to