Re: Lazy evaluation?

From: Date: Wed, 16 Jan 2002 16:25:38 +0000
Subject: Re: Lazy evaluation?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-80741@lists.php.net to get a copy of this message
aha! see, i didn't understand the whole picture. so, let me see if i can create another question. suppose if (($a_good = ($a == 'a')) && ($b_good = ($b == 'b'))) blahblahblah(); are you saying, that $b_good should always have the result of ($b == 'b') even if $a != 'a'? that's not what my test shows (hi bogdan :) so, is there something other than && that forces the other half to be evaluated? interesting... mike on 8/23/01 5:19 PM, TD - Sales International Holland B.V. at td@salesint.com wrote: > On Wednesday 16 January 2002 16:18, you wrote: > > I think the cause is, which is lacking in the reply below, that if you have > like > if ((function1(val, val)) && (function2(val, val)) blabla(); > > you still want function2 to be executed because it does things necessary for > your script, however, if one of them returns false you don't want blabla() to > be executed. If that isn't the case you should use or or one of the other > operators > > not too sure about that tho' but i'm sure I'll be corrected if that isn't > the > case :-) > >> on 1/16/02 5:57 AM, Miles Thompson at milesthompson@ns.sympatico.ca wrote: >>> For "or" statements it does, but not && or xor. I don't know >>> about you, >>> but I wouldn't want lazy evaluation on a conditional statement involving >>> "and". >> >> i'm new to all this stuff, so i'll bite. hopefully someone can explain what >> i'm missing. >> >> if i have a statement like >> >> if (($a == 'a') && ($b == 'b')) blahblahblah(); >> >> and, $a != 'a'. >> >> why should php even look at the value for $b while evaluating this line? >> shouldn't the if fail after evaluating $a? >> >> thanks, >> mike >> >> -- mike cullerton michaelc at cullerton dot com > -- mike cullerton michaelc at cullerton dot com

« previous php.general (#80741) next »