[Nfd-dev] NFD CodeStyle rule 76

Junxiao Shi shijunxiao at email.arizona.edu
Sun Mar 30 19:18:11 PDT 2014


Hi Alex

Amended rule 76 gives an example of a switch statement:

switch (condition) {
  case ABC:
    statements;
    // Fallthrough

  case DEF:
    statements;
    break;

  case XYZ:
    statements;
    break;

  default:
    statements;
    break;
}


Rule 76 also states: Note that each case keyword is indented relative to
the switch statement as a whole.
This note is not eliminated by the amendment.


Amended rule 68 permits an additional block layout:

while (!done)
  {
    doSomething();
    done = moreToDo();
  }



There is a conflict when two amendments are applied together.

The note in rule 76 causes case keywords to indent *relative to* the
switchkeyword.
The example given indicates that the relative offset is 2 spaces.

However, when the additional block layout permitted by amended rule 68 is
used, case keywords would end up at the same column with { } brackets.

switch (condition)
  {

  case ABC:

    statements;

    break;

  default:

    statements;

    break;

  }


Is this the intended layout, or should case keywords be indented 4 spaces
after switch keyword (2 spaces after { } brackets)?

switch (condition)
  {

    case ABC:

      statements;

      break;

    default:

      statements;

      break;

  }


Yours, Junxiao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/nfd-dev/attachments/20140330/dd2484c2/attachment.html>


More information about the Nfd-dev mailing list