Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42703 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75007 invoked from network); 19 Jan 2009 11:57:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jan 2009 11:57:26 -0000 Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=unknown; 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:43438] helo=h1149922.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id ED/24-50097-5AA64794 for ; Mon, 19 Jan 2009 06:57:26 -0500 Received: from MBOERGER-ZRH.corp.google.com (p5086450E.dip.t-dialin.net [80.134.69.14]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by h1149922.serverkompetenz.net (Postfix) with ESMTP id BBF3F11F276; Mon, 19 Jan 2009 12:57:22 +0100 (CET) Date: Mon, 19 Jan 2009 12:57:21 +0100 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <995073772.20090119125721@marcus-boerger.de> To: Stanislav Malyshev CC: Ionut Gabriel Stan , internals@lists.php.net In-Reply-To: <49743A89.3070607@zend.com> References: <1016989528.20090112233204@marcus-boerger.de> <496BCD33.4080703@zend.com> <133861245.20090113225847@marcus-boerger.de> <496D2074.3070303@zend.com> <496DD269.4050701@gmail.com> <496E12CE.2080403@zend.com> <1956503865.20090117212630@marcus-boerger.de> <49743A89.3070607@zend.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [RFC] prototyping From: helly@php.net (Marcus Boerger) Hello Stanislav, Monday, January 19, 2009, 9:32:09 AM, you wrote: > Hi! >> It is a mess right now. You assign a closure to another method and get >> access to the original owners private members. That is not only unexpected > Could you give a code example? I'm not sure I understand what you mean > by access (or "assign closure to a method" for that matter) - if access > provided by the closure, it's exactly the intent of the closure. If some > other access, then please explain which one. class Foo { private $myVeryOwnData; function bla { $this->bigMEss = function () { return $this->myVeryOwnData; } } } $o = new Foo; $f = $o->bla; echo $f(); class Bar { function baz{} { $this->xyz = $o->bla; // or $f; // I am very sorry but I would expect the closure to rebind $this as // $this always points to the bound object. And how is this different? // If the different is that the closure is already bound and that is // what you want, then we need ways to do just that. And not inventing // new ways to deal with $this. } } $onother = new stdClass; $another->blabla = $f; // yet again a very unexpected $this. If this really was to be bound to a $this at the creation, then we'd put it into the scope binding list and not have it be handled implicitly. But then we cannot do that with the current c level api. So instead you created brand new rules, which unfortunately is the PHP way. So how would I copy a closure instead of rebinding it? I would use PHP's current established semantics for that. That is I'd do: $this->closure = clone $closure; $this->closure = $closure->copy(); How would I prevent automatic $this binding? $closure = static function().... > -- > Stanislav Malyshev, Zend Software Architect > stas@zend.com http://www.zend.com/ > (408)253-8829 MSN: stas@zend.com Best regards, Marcus