Am 06.12.2014 04:04 schrieb "Yasuo Ohgaki" <yohg...@ohgaki.net>: > > $top = array_pop(f2()); > > is better than > > $v = f2(); > $top = array_pop($v); > > Is there anyone who likes latter?
It is bad practise either way, having poor f2() build up a whole array that is then immediately thrown away. The second case is worse due to missing an unset($v), keeping the array around for eternity... I personally do find it annoying to "need" a variable there, just because the outer called function happens to take a parameter as reference - which is not visible at the calling place at first glance, thus making me wonder, when only looking there, what the hell that scratch variable is supposed to accomplish... In practise this part of the issue didn't arise that often, compared to the other part: only being able to return variables by reference. Concretely, that hit me when writing return-by-reference offsetGet() methods that sometimes need to return null. Not that bad, in a sense, because the scratch-null-holding-variable is contained in the place where it belongs, the offsetGet method itself - but nevertheless strange... best regards Patrick