[Nfd-dev] NFD CodeStyle rule 76
Alex Afanasyev
afanasev at cs.ucla.edu
Tue Apr 1 13:58:12 PDT 2014
Hi guys,
I have updated rule 76 to be more consistent with other style changes:
(changed 76) switch statement should have one of the two of following forms:
switch (condition) {
case ABC:
statements;
// Fallthrough
case DEF:
statements;
break;
case XYZ:
statements;
break;
default:
statements;
break;
}
or
switch (condition)
{
case ABC:
statements;
// Fallthrough
case DEF:
statements;
break;
case XYZ:
statements;
break;
default:
statements;
break;
}
These two variants is what emacs will do when our gnu style is selected. Previous variant was directly copied from the base rules and I don't think I ever followed that one.
---
Alex
On Mar 30, 2014, at 7:18 PM, Junxiao Shi <shijunxiao at email.arizona.edu> wrote:
> 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 switch keyword.
> 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/20140401/d666809a/attachment.html>
More information about the Nfd-dev
mailing list