Thanks for "static function ()" idea, it's much better and consistent
than "function () use ($this)". I think we should go this way.
Do you see any other issues with the patch?
Thanks. Dmitry.
Alexander Wagner wrote:
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
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php