Subject: Re: commoning up code that changes uids and gids
To: David Laight <david@l8s.co.uk>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 04/05/2003 19:03:45
On Sat, 5 Apr 2003, David Laight wrote:

> > > for instance how would you read:
> > >  	svuid = 1 + (ruid == p->p_cred->p_ruid) ? -1 : euid;
> >
> > In the first place, I'd write this as
> >
> >    	svuid = 1 + ((ruid == p->p_cred->p_ruid) ? -1 : euid);
> >
> > and thus would not have any problem reading it. Parenthesis good.
>
> I thought you might :-) which indicates that the parenthesis confused you!
> Learn table 2-1 (P53 of K&R 2), it isn't hard.

Why?

1) that would mean memorizing something that I think was poorly thought
out, and will serve to confuse me when I work with other languages.

2) As Greg points out, we're talking about code being read by lots of
people. Saying you HAVE to know all of the operator hierarchy makes our
code very inaccessable.

> Personally I find that, in complex expressions, unnecessary parenthesis
> make parsing harder not easier.  The () around the first operand of ?:
> are particulaly pointless, as are those the the RHS of = (and other
> assignment operators).

They may be pointless to you, but they are not pointless for others.
That's the point. :-) This is a question where we need to do more than
just what's convenient for us.

Take care,

Bill