Ticket #1864 (new RFC)

Opened 4 years ago

Last modified 3 years ago

[RFC] Change coding standard to avoid 2 space outdent.

Reported by: bacek Owned by: jkeenan
Priority: normal Milestone: 2.11
Component: coding_standards Version: 2.10.0
Severity: medium Keywords:
Cc: cotto, whiteknight Language:
Patch status: Platform:

Description

Hello.

Current coding standard requires 2 space indent on switch/case indent. I would like to propose to change it to 4 space and close #1547 as "wontfix".

Basically I speak about this patch:

diff --git a/docs/pdds/pdd07_codingstd.pod b/docs/pdds/pdd07_codingstd.pod
index 8741a1b..52dc866 100644
--- a/docs/pdds/pdd07_codingstd.pod
+++ b/docs/pdds/pdd07_codingstd.pod
@@ -110,11 +110,6 @@ the level of indenting to increase.
 
 =item *
 
-Labels (including case labels) must be outdented two columns relative to the
-code they label.
-
-=item *
-
 Closing braces for control structures must line up vertically with the
 start of the control structures; e.g. C<}> that closes an C<if> must
 line up with the C<if>.

Or at least change "including" to "excluding".

-- Bacek

Change History

Changed 4 years ago by jkeenan

I think these would be the affected files:

src/atomic/gcc_x86.c
src/dynoplibs/sys.ops
src/io/socket_unix.c
src/io/socket_win32.c
src/io/unix.c
src/oo.c
src/packfile/pf_items.c
src/pbc_disassemble.c
src/pbc_dump.c
src/pmc/unmanagedstruct.pmc
src/string/encoding/shared.c

[need to fully verify]

kid51

Changed 4 years ago by plobsing

-1 # <3 2-space outdent

Changed 4 years ago by jkeenan

  • cc cotto, whiteknight added

Do the architect and product manager have opinions on this? (cc-ing the likely suspects)

Changed 4 years ago by whiteknight

I personally dislike the 2-space outdent, but I don't dislike it enough to tell everybody else to change it.

Changed 4 years ago by cotto

Just to clarify, this is what bacek is talking about:

switch (errno) {
    case EINTR:
        goto AGAIN;
    case EINPROGRESS:
        goto AGAIN;
    case EISCONN:
        return 0;
    default:
        return -1;
}

If someone wants to update our code to match the new coding standard and update our editor config files (editor/*), I'm fine with this.

Changed 3 years ago by jkeenan

  • owner set to jkeenan
  • component changed from none to coding_standards

1. Concession in advance: I don't know editors other than vim. It appears we also support emacs and kate.

2. Concession in advance: I have never attempted to write editor files even for vim.

3. The only code I could find under editors/ that appeared to be relevant to this discussion was this part of indent_pir.vim:

     19 fun! PIRIndent()
...
     59     let LABEL = '^\s*\k\+:'
     60 
     61     if prevline =~? SUB
     62         let ind = ind + &sw
     63     endif
     64 
     65     if prevline =~? RETURNBLOCK
     66         let ind = ind + &sw
     67     endif
     68 
     69     if prevline =~? LABEL
     70         let ind = ind + 2
     71     endif
     72 
     73     if thisline =~? END
     74         let ind = ind - &sw
     75     endif
     76 
     77     if thisline =~? LABEL
     78         let ind = ind - 2
     79     endif
     80     
     81     return ind
     82 
     83 endfun

If I changed 2 to 4 at lines 70 and 78, would that effect the change bacek desires? Would that be wise?

Thank you very much.

kid51

Note: See TracTickets for help on using tickets.