On Sun, 25 Apr 2004, ahmad khalifa wrote:
> > >
> > >   if (!(type == STRONG_R
> > >   || type == STRONG_L
> > >   || type == WEAK_BN
> > >   || type == WEAK_EN
> > >   || type == WEAK_AN
> > >   || type == NEUTRAL_B
> > >   || type == NEUTRAL_S
> > >   || type == NEUTRAL_WS
> > >   || type == NEUTRAL_ON))
> > >     abort ();
> >
> >Can you tell why you think it needs more parentheses?  It basically
> >says
> >
> >   if (!(expression))
> >     abort ();
> >What's wrong with that, and why would an additional pair of enclosing
> >parens fix that?
>
> are you sure expression is evaluated correctly ? thats what the parens
> are for... 1 month ago i would have never thought that this would be a
> problem, but after debugging minibidi line by line, i found out that
> sometimes this happens, probably because ' || ' and ' == ' have the same
> evaluation priority or something.

Apparently not in this case.  And no, they don't have the same
priority.  The idiom is that something like this:

(a == b || c == d && e == f || g == h)

Works as you expect:

((a == b) || ((c == d) && (e == f)) || (g == h))


--behdad
  behdad.org
_______________________________________________
Developer mailing list
[EMAIL PROTECTED]
http://lists.arabeyes.org/mailman/listinfo/developer

رد على