On Thu, March 15, 2012 9:21 am, Klaus Silveira wrote:
> Hello internals,
>
> I've been involved in a discussion at the PHP Standards Group and we
> recently had the following statement:
>
> *Say you had a loop, and inside that loop you wanted to modify a param
>> **update the key:**
>> **foreach($a as $key => $val) {
>> **   $a[$key] = someLong(functionCalls(hereThat($spanOver85Chars)));
>> **}**
>> **If this exceeded the line width, you would have to split things
>> like
>> **this over a few lines, storing the val temporarily in a zval's
>> until
>> **you reached your end computation. Therefore allocating more memory
>> **iteratively. *
>
>
> I'm curious about this. Can anyone confirm it or a benchmark should be
> made?

I don't see why your standard can't allow for:
      $a[$key] =
        someLong(
          functionCalls(
            hereThat(
              $spanOver85Chars
        ) ) );

Some folks insist that the closing parens be on separate lines. 
They're isomorphic to me, so I just put them on one line.

So long as the count matches and they "line up" in reverse order,
indented properly, it's all good.

But then, I cut my teeth on Lisp, where a zillion parens to close off
almost anything is the norm. :-)

PS
If you want a benchmark for how much 3 or 4 temporary zvals takes,
knock yourself out.

Also consider trying this in a second benchmark:

//don't create / destroy zvals in the loop, hopefully
$someLong = '';
$functionCalls = '';
$hereThat = '';
foreach ($a as $key => $value){
  ...
}

PPS
I'm assuming $a is not within the Coding Standard :-)


-- 
brain cancer update:
http://richardlynch.blogspot.com/search/label/brain%20tumor
Donate:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FS9NLTNEEKWBE



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

Reply via email to