ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-dev
php-dev
Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP
by Alexander Wagner other posts by this author
Jun 27 2008 3:05PM messages near this date
RE: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP | Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP
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

-- 
The army is launching a military theme park in Virginia with high-tech 
simulator rides.
The Project is expected to cost 900 million dollars and none of the rides will 
ever end.
 - Studio 60

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Thread:
Christian Seiler
Wez Furlong
Dmitry Stogov
Stanislav Malyshev
Alexander Wagner
Dmitry Stogov
Andi Gutmans
Christian Seiler
Lukas Kahwe Smith
Sebastian Bergmann
Marcus Boerger
Markus Fischer
Troels Knak-Nielsen
Christian Seiler
Dmitry Stogov
Larry Garfield
Christian Seiler
Dmitry Stogov
Christian Seiler
Lars Strojny
Stanislav Malyshev
Marcus Boerger
Lars Strojny
Troels Knak-Nielsen
Larry Garfield
Marcus Boerger
Dmitry Stogov
Andi Gutmans
Alexander Wagner
Andi Gutmans
Alexander Wagner
Alexander Wagner
Christian Seiler
Alexander Wagner
Lars Strojny
Dmitry Stogov
Marcus Boerger
Lars Strojny
Dmitry Stogov
Alexey Zakhlestin
Federico Lebron
Dmitry Stogov
Rodrigo Saboya
lenar
Larry Garfield
Stanislav Malyshev
Marcus Boerger
Alexander Wagner
Lars Strojny
Larry Garfield
Robert Cummings
Rodrigo Saboya
Alexander Wagner
Christian Seiler
Chris Stockton
Alexander Wagner
Troels Knak-Nielsen
Andi Gutmans
Marcus Boerger
Christian Seiler
Lukas Kahwe Smith
Gwynne Raskind
Andi Gutmans
Christian Seiler
Stanislav Malyshev
Kalle Sommer Nielsen
Troels Knak-Nielsen
Lars Strojny
Alexander Wagner
Stanislav Malyshev
Alexander Wagner
Andi Gutmans
Marcus Boerger
Kalle Sommer Nielsen
Troels Knak-Nielsen
Stanislav Malyshev
Alexey Zakhlestin
Chris Stockton
Alexey Zakhlestin
Gwynne Raskind
Stanislav Malyshev
Christian Seiler
Gwynne Raskind
Stanislav Malyshev
Richard Quadling
Christopher Jones
Marcus Boerger
Steph Fox
Christian Seiler
Marcus Boerger
Stanislav Malyshev
Lars Strojny
Christian Seiler
Stanislav Malyshev
Marcus Boerger
Marcus Boerger
Andrei Zmievski
Stanislav Malyshev
Stanislav Malyshev
Alexey Zakhlestin
Chris Stockton
Christian Seiler
Christian Seiler
Larry Garfield
Edward Z. Yang
Christian Seiler
Larry Garfield
Christian Seiler
Nathan Nobbe
Christian Seiler
Alexey Zakhlestin
Larry Garfield
Philip Olson

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved