Re: Re: New wiki account

From: Date: Sat, 12 May 2012 14:59:57 +0000
Subject: Re: Re: New wiki account
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-60537@lists.php.net to get a copy of this message
On Sat, May 12, 2012 at 12:22 AM, Alexander Moskaliov <irker@irker.net> wrote: > 2012/5/12 Dmitri Ravazin <ravazin@gmail.com> >> >> Yes... That's just what I had in the RFC. > > > Not at all. In RFC you use first expression in "for ... else" statement as > condition for "else" statement. > >> if (some_very_expensive_and_ugly_looking_calculation($array) < 0) { >> >> } > > >  I think it correct to use the second expression before the start of > looping, as I described in previous mail. That "if" is testing the inverse condition of $exp2 from "for", so it will yield exactly the same result. If some_very_expensive_and_ugly_looking_calculation($array) is less than 0, then it can't be greater of equal than 0 at the same time, so "for" loop will not be entered. It is assumed, of course, that the function does not modify the data. If it did, then yeah, we'd need a temporary variable.

« previous php.internals (#60537) next »