On Sat, May 12, 2012 at 12:22 AM, Alexander Moskaliov <ir...@irker.net> wrote:
> 2012/5/12 Dmitri Ravazin <rava...@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.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to