Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP
by Alexander Wagner other posts by this author
Jun 27 2008 12:31PM 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 am not sure I like the idea of explicit $this.
> [..] If we ever discover this is a huge issue
Implicit unoptimized $this is never going to be a "huge issue", because it is
not badly broken, only sublty.
My crystal ball tells me that the following is going to happen:
- Many people who use closures will expierience a slight increase in memory
consumption due to closures. They won't notice though, unless they run on a
memory_limit with little margin for error.
- Developers with objects that use a lot of memory (e.g. because they contain
large strings or hold references to many other objects) will expierience a
significant increase in memory consumption (constant or linear) that may be
enough to cause noticable performance degradation and pop quite a few memory
limits. This is going to be relatively rare, but it will happen regularly.
PHP has a lot of users using shared hosting services.
- A very small number of developers will manage to implement an algorithm
whose space complexity is changed from O(1) to O(n) or worse, which can
easily cause a catastrophic increase in memory consumtion, even when PHP is
operating without memory limit.
Also, most of the developers to whom this happens will either not notice at
all or be unable to give accurate feedback, so if this does become a
significant problem, you may never find out.
> we can always add support for something like "static function() {}"
That kind of implies that the lambda-function is part of the class because it
was created inside the class. I don't like this notion. Membership in the
class should be reserved for actual members.
You could start with explicit $this, which is inconvenient but safe.
If enough developers complain about the inconvenience, you have a lot of time
to think about how to implement an optimized implicit $this. I don't see any
BC-problems here.
"Start safe, optimize later" seems sounder than "Start sublty broken, fix
later".
Gesundheit
Wag
--
The animals of Australia can be divided into three categories: Poisonous, Odd,
and Sheep.
- Douglas Adams
--
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
|