Jonathan Scott Duff wrote:

> On Thu, Dec 12, 2002 at 09:43:26AM -0600, Adam D. Lopresto wrote:
> 
> > So basically we can leave off the parentheses in the usual cases,
> > but they're still required when you're doing something unusual or
> > that would otherwise be hard to read.
> 
> Which is simpler?  "You don't need parentheses except in the case that
> you're doing something unusual"  or "you always need parentheses"
> 
> Surely the latter.

The former could be claimed to be analogous to use of parentheses with
operators (or indeed in maths generally): there are precedence rules
which mean that much of the time parens aren't needed (but you can
always choose to add them), but when you want to do something else you
need to put them in.

When teaching programming I've encountered several people make decisions
along the lines of "It's always easier to put the parens in because then
I keep full control and I'm not leaving it to 'chance' and I can see
what's being done when without having to memorize the precedence table".

I don't mind that in simple experssions, but if I see an expression with
seven pairs of parens then I've got to stop for a couple of moments to
check out which ones balance and what the expression is doing.  Even if
all seven pairs are redundant it still takes time to determine that,
whereas a paren-less expression can be noted quickly as not doing
anything odd.

If six of those pairs of parens were superfluous but one of them was
overriding precedence it isn't easy to spot which is which, when
compared with an expression which only had the required pair.

> It seems to me that requiring the parens will cause less confusion in
> the long run.

I think different people find different things confusing.  Were Adam's
rule to be in place, there's nothing to stop some people choosing to
ignore it and include the parens all the time.  (Just as in Perl 5 some
people put parens on all built-in function calls all the time.)

> But, I'm just waiting to see what brilliant ideas Larry et alia come
> up with  :-)

Quite.

Smylers

Reply via email to