I thought about use($this) too. :)
I'll try to implement it in the next version of the patch.

Thanks. Dmitry.

Alexander Wagner wrote:
> On Friday 27 June 2008, Andi Gutmans wrote:
>> I lean towards the use(...) syntax.
> 
> Me too.
> 
>>>   * I provided a patch variant that only stores $this if $this is
>>>     explicitely used inside a closure [..]
>> Safest not to take shortcuts. You get yourself into trouble with things
>> which will stop working. -1 on this optimization.
> 
> I believe that always implicitly referencing $this is a mistake.
> Not only does it turn every lambda that is created inside an object into a 
> heavier closure, it also makes it impossible for the closure to outlive the 
> object, which can, in some rare cases, dramatically increase memory 
> consumption, in which case things will also stop working.
> Also, given how many people put all their code into classes, this may cause 
> problems more often than we might think, although the wasted memory will 
> usually go undetected, making this whole thing a source for nasty heisenbugs.
> 
> If the optimization of only referencing $this when it is actually used is a 
> dangerous shortcut, the alternative should be to not implicitly reference 
> $this at all and require it to be importet through "use ($this)".
> 
>>>   * Do you want closures in PHP?
>> I think most people here feel it's useful or are at least indifferent.
> 
> There are those who want them and those who don't know that they want them.
> 
> Gesundheit
>   Wag
> 

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

Reply via email to