Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49206 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98443 invoked from network); 5 Aug 2010 13:54:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Aug 2010 13:54:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.22 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.22 smtp2.ist.utl.pt Linux 2.6 Received: from [193.136.128.22] ([193.136.128.22:58159] helo=smtp2.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 89/50-30659-492CA5C4 for ; Thu, 05 Aug 2010 09:54:30 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp2.ist.utl.pt (Postfix) with ESMTP id C50CF70042C3 for ; Thu, 5 Aug 2010 14:54:25 +0100 (WEST) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp2.ist.utl.pt ([127.0.0.1]) by localhost (smtp2.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id rdISVTuWUre7 for ; Thu, 5 Aug 2010 14:54:25 +0100 (WEST) Received: from mail2.ist.utl.pt (mail.ist.utl.pt [IPv6:2001:690:2100:1::8]) by smtp2.ist.utl.pt (Postfix) with ESMTP id 835CA70042B8 for ; Thu, 5 Aug 2010 14:54:25 +0100 (WEST) Received: from cataphract-old.dulce.lo.geleia.net (52.152.108.93.rev.vodafone.pt [93.108.152.52]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id 4771B2008D23 for ; Thu, 5 Aug 2010 14:54:25 +0100 (WEST) Content-Type: multipart/mixed; boundary=----------czunXZlclj3M0jK4CsYbKw To: internals@lists.php.net References: Date: Thu, 05 Aug 2010 14:54:21 +0100 MIME-Version: 1.0 Organization: =?iso-8859-15?Q?N=FAcleo_de_Eng=2E_Biom=E9dica_?= =?iso-8859-15?Q?do_IST?= Message-ID: In-Reply-To: User-Agent: Opera Mail/10.60 (Win32) Subject: Re: [PHP-DEV] (now with PATCH) Closures, rebinding and scopes From: glopes@nebm.ist.utl.pt ("Gustavo Lopes") ------------czunXZlclj3M0jK4CsYbKw Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Hi I've modified Closure::bindTo/Closure::bindTo so that they accept another argument that defines the new scope. This can either be an object (its class is used as the scope) or a class name. I changed the current behavior so that: * If the scope is not given, the current one is kept. This permits changing the bound instance without changing the calling scope. The current behavior (set the scope to the class of the new bound instance) makes useless rebinding of closures that were defined up in the class hierarchy. * I also changed the order of the arguments of Closure::bindTo so that I could unify Closure::bind and Closure::bindTo under a single implementation which plays nice with zend_parse_method. Additionally, I added the method Closure::getScope, which returns the currently set calling scope of the closure. Finally, I added four tests. Tests closure_038 and closure_039 fail. Both present memory corruption and, in addition to that, closure_039 also gives incorrect results because the rebounding confuses the cache. Note that these problems were already present (they weren't caused by the changes, as far as I know). I attached the logs. -- Gustavo Lopes ------------czunXZlclj3M0jK4CsYbKw--