forcing evaluation in if()

Mariano rotoshi at yahoo.com
Fri Nov 17 04:04:39 PST 2006


== Quote from xs0 (xs0 at xs0.com)'s article
> > One question about && and || optimization:
> >
> > Is there some way to specify that I need to evaluate the 2 sides of the
> > comparer?
> >
> > (something like &&& or ||| )
> >
> > note:  "if( And( left() , right() ) )" or similar is not a solution :-)
> & and | should do the trick :)
> xs0

Well, the '&' doesn't always work, considering the ambibalence between integers and booleans.
For instance:

cmp(a,b) & cmp(b,c)

will be considered false even if the 3 strings are different, if they return values (for example) 1 and 2; 1 & 2 is 0
(01 & 10). Same thing with XOR. Nevertheless, the OR would work, and you could use !(!a | !b) instead if &.

Mariano.



More information about the Digitalmars-d mailing list