Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38657 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33480 invoked from network); 27 Jun 2008 14:50:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jun 2008 14:50:06 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Windows 2000 SP4, XP SP1 Received: from [212.25.124.162] ([212.25.124.162:56858] helo=mx1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7F/43-33826-A1EF4684 for ; Fri, 27 Jun 2008 10:50:05 -0400 Received: from ws.home ([10.1.1.1]) by mx1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 27 Jun 2008 17:50:14 +0300 Message-ID: <4864FE15.3020008@zend.com> Date: Fri, 27 Jun 2008 18:49:57 +0400 User-Agent: Thunderbird 2.0.0.14 (X11/20080501) MIME-Version: 1.0 To: Alexander Wagner CC: internals@lists.php.net, Andi Gutmans , Christian Seiler , Stas Malyshev References: <4856A547.3080801@gmx.net> <4863C299.1080002@gmx.net> <698DE66518E7CA45812BD18E807866CE01BD0E9A@us-ex1.zend.net> <200806271601.33407.waqner@gmx.net> In-Reply-To: <200806271601.33407.waqner@gmx.net> X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 27 Jun 2008 14:50:14.0796 (UTC) FILETIME=[1BB14CC0:01C8D865] Subject: Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP From: dmitry@zend.com (Dmitry Stogov) 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 >