From owner-cvs-all Fri Jul 20 4:38: 9 2001 Delivered-To: cvs-all@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 23D0037B403; Fri, 20 Jul 2001 04:37:59 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id VAA00931; Fri, 20 Jul 2001 21:37:56 +1000 Date: Fri, 20 Jul 2001 21:35:41 +1000 (EST) From: Bruce Evans X-Sender: bde@besplex.bde.org To: Ruslan Ermilov Cc: Bruce Evans , cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/share/man/man9 style.9 In-Reply-To: <20010720113310.C30828@sunbay.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, 20 Jul 2001, Ruslan Ermilov wrote: > What about this block? > > if (mylevel == SLC_DEFAULT) { > slctab[(int)func].current.flag = flag; > slctab[(int)func].current.val = val; > flag |= SLC_ACK; > } else if (hislevel == SLC_CANTCHANGE && > mylevel == SLC_CANTCHANGE) { > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > flag &= ~SLC_LEVELBITS; > flag |= SLC_NOSUPPORT; > slctab[(int)func].current.flag = flag; > } > > This is using style(9)'s second-level of four indents rule. > But, strictly speaking, `else if' is not an operator, this > is `else' operator followed by the `if' operator. So if we > would use the second-level indent of four spaces relatively > to the `if' operator, we would get: I would call both `if' and `else' keywords, not operators. > if (mylevel == SLC_DEFAULT) { > slctab[(int)func].current.flag = flag; > slctab[(int)func].current.val = val; > flag |= SLC_ACK; > } else if (hislevel == SLC_CANTCHANGE && > mylevel == SLC_CANTCHANGE) { > flag &= ~SLC_LEVELBITS; > flag |= SLC_NOSUPPORT; > slctab[(int)func].current.flag = flag; > } > > Which is much better, no? No :-). > Hell, but then, I guess, we would need > to indent lines within `else if' block relative to `if' as well. Yes, only of the main advantages of the 4-char continuation indent rule is that it doesn't depend on the context. If the continuation indent depended on the context, then you would get continuation indents all over the place and need complicated rules to make them deterministic. I think, strictly speaking, `if' after `else' begins a new clause so it needs a first-level indent: if (...) { ... } else { if (...) { ... } else { if (...) { ... } } } but `else if' is idiomatic -- no one writes an else-if ladder like the above. Anyway, the continuation indent rule is at the lexical level, so it doesn't apply to `else if'. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message