Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38661 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36205 invoked from network); 27 Jun 2008 19:30:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jun 2008 19:30:54 -0000 Authentication-Results: pb1.pair.com smtp.mail=waqner@gmx.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=waqner@gmx.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.net designates 213.165.64.20 as permitted sender) X-PHP-List-Original-Sender: waqner@gmx.net X-Host-Fingerprint: 213.165.64.20 mail.gmx.net Linux 2.6 Received: from [213.165.64.20] ([213.165.64.20:47424] helo=mail.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 12/F1-24558-CEF35684 for ; Fri, 27 Jun 2008 15:30:53 -0400 Received: (qmail invoked by alias); 27 Jun 2008 19:30:49 -0000 Received: from p5087CE5B.dip.t-dialin.net (EHLO p5087ce5b.dip.t-dialin.net) [80.135.206.91] by mail.gmx.net (mp049) with SMTP; 27 Jun 2008 21:30:49 +0200 X-Authenticated: #27239598 X-Provags-ID: V01U2FsdGVkX19OHrU8nHNO5jcPNdwV2LNx6l47xVfTz8gvOzd/+J mRMsVHGTDK5hvA To: internals@lists.php.net Date: Fri, 27 Jun 2008 21:30:49 +0200 User-Agent: KMail/1.9.9 Cc: "Andi Gutmans" , "Dmitry Stogov" , "Christian Seiler" , "Stas Malyshev" References: <4856A547.3080801@gmx.net> <48651D20.6050301@zend.com> <698DE66518E7CA45812BD18E807866CE01BD0FA5@us-ex1.zend.net> In-Reply-To: <698DE66518E7CA45812BD18E807866CE01BD0FA5@us-ex1.zend.net> MIME-Version: 1.0 Content-Disposition: inline Message-ID: <200806272130.50007.waqner@gmx.net> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 Subject: Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP From: waqner@gmx.net (Alexander Wagner) 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