Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Mar 2002 01:36:51 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Mark Murray <mark@grondar.za>
Cc:        <obrien@FreeBSD.org>, Will Andrews <will@csociety.org>, <cvs-committers@FreeBSD.org>, <cvs-all@FreeBSD.org>
Subject:   Re: cvs commit: src/usr.bin/rwall rwall.c 
Message-ID:  <20020308012014.Q1004-100000@gamplex.bde.org>
In-Reply-To: <200203071316.g27DGlRV011103@grimreaper.grondar.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 7 Mar 2002, Mark Murray wrote:

> > On Thu, Mar 07, 2002 at 12:06:49PM +0000, Mark Murray wrote:
> > > > 2. please review the C idiom of short-circuit evaluation.
> > >
> > > I know this. See style(9) on complicated expressions.
> >
> > Please point out which section you are referring to.  I glanced thru
> > style(9) wondering if the if() style changes are mandated.  Searching on
> > "assignment" or "complicated" gave nothing.  And the examples such as:
> >
> >     if ((four = malloc(sizeof(struct foo))) == NULL)
> >
> > seem to approve the style.
>
> (Lousy) example. I hate it when examples become rules.
>
> The section I was referring to is:
>
>  Unary operators do not require spaces, binary operators do.  Do not use
>  parentheses unless they are required for precedence or unless the state-
>  ment is confusing without them.  Remember that other people may confuse
>  easier than you.  Do YOU understand the following?
>
>          a = b->c[0] + ~d == (e || f) || g && h ? i : j >> 1;
>          k = !(l & FLAGS);

This is a silly example which made more sense before it was explained in
rev.1.23.  You weren't meant to understand this.  It is a random C
expression that needs parentheses and perhaps splitting up because it is
very far from the C idiom.  The expression that was broken in rwall.c
is the oppposite.  It is idiomatic, so it is easier to understand when
it is not split up.  OTOH, the simpler expression for `four' above
doesn't benefit much from being written on one line, since it doesn't
need the `||' idiom.

rev.1.23 still objected to by: bde

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020308012014.Q1004-100000>