Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38655 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17717 invoked from network); 27 Jun 2008 14:01:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jun 2008 14:01:40 -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:55378] helo=mail.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 40/30-33826-1C2F4684 for ; Fri, 27 Jun 2008 10:01:40 -0400 Received: (qmail invoked by alias); 27 Jun 2008 14:01:34 -0000 Received: from p5087CE5B.dip.t-dialin.net (EHLO p5087ce5b.dip.t-dialin.net) [80.135.206.91] by mail.gmx.net (mp034) with SMTP; 27 Jun 2008 16:01:34 +0200 X-Authenticated: #27239598 X-Provags-ID: V01U2FsdGVkX19tF14eNVBtf51oKlIeDyhq0nylaEkkOPaapgIvE3 MVgTloZGkxreZl To: internals@lists.php.net Date: Fri, 27 Jun 2008 16:01:33 +0200 User-Agent: KMail/1.9.9 Cc: "Andi Gutmans" , "Christian Seiler" , "Dmitry Stogov" , "Stas Malyshev" References: <4856A547.3080801@gmx.net> <4863C299.1080002@gmx.net> <698DE66518E7CA45812BD18E807866CE01BD0E9A@us-ex1.zend.net> In-Reply-To: <698DE66518E7CA45812BD18E807866CE01BD0E9A@us-ex1.zend.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200806271601.33407.waqner@gmx.net> 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 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