Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43324 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92270 invoked from network); 11 Mar 2009 22:35:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Mar 2009 22:35:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 85.214.94.56 as permitted sender) X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 85.214.94.56 aixcept.net Linux 2.6 Received: from [85.214.94.56] ([85.214.94.56:36170] helo=h1149922.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 40/51-09289-4BC38B94 for ; Wed, 11 Mar 2009 17:35:32 -0500 Received: from dhcp-172-26-94-64.nyc.corp.google.com (unknown [72.14.228.89]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by h1149922.serverkompetenz.net (Postfix) with ESMTP id E385811FBCF; Wed, 11 Mar 2009 23:35:28 +0100 (CET) Date: Wed, 11 Mar 2009 23:35:27 +0100 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <306205231.20090311233527@marcus-boerger.de> To: Nate Abele CC: PHP Development In-Reply-To: <6E2164EC-F333-4E89-8EBD-6618BA321CD6@cakephp.org> References: <6E2164EC-F333-4E89-8EBD-6618BA321CD6@cakephp.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Questions on closures and visibility From: helly@php.net (Marcus Boerger) Hello Nate, Wednesday, March 11, 2009, 9:25:23 PM, you wrote: > Hi all, > Since around alpha1, I've been doing some experimenting with closures, > most recently in the form of a filter chain implementation, and I've > discovered that as of beta1 (as was noted in the "removal-of-$this" > RFC) that there is no way to access private or protected members of > any class inside a closure, regardless of where it is defined. > I realize that the question of implicit $this support for closures has > already been discussed and decided upon temporarily (and I certainly > have no wish to rehash it again), however, it seems logical that even > without being bound to an object, closures should still inherit the > scope in which they're defined. Otherwise, this creates a confusing > inconsistency within the language. At the moment it simply is impossible to allow $this. Simply becasue we could not solve resolving it correctly, or figuring out the scope correctly. An attempt of mine to solve the issues first looked good and then just brought up more issues and the only way to solve them was to make everything slower. So we decided to keep closures as external entities that are not bound to the scope they are created in. In the same way we do not bind anythign magically. Also it appears that you probably want a real callback if you ave to access private or protected members. At least from a pure design stanpoint that is more than obvious. Please leave it for the moment, we are far to close in PHP 5.3 release process to do somethign about it now. Best regards, Marcus