Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46079 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21137 invoked from network); 18 Nov 2009 09:53:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Nov 2009 09:53:30 -0000 Authentication-Results: pb1.pair.com header.from=rquadling@googlemail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=rquadling@googlemail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.220.227 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@googlemail.com X-Host-Fingerprint: 209.85.220.227 mail-fx0-f227.google.com Received: from [209.85.220.227] ([209.85.220.227:40120] helo=mail-fx0-f227.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B5/D0-16241-914C30B4 for ; Wed, 18 Nov 2009 04:53:30 -0500 Received: by fxm27 with SMTP id 27so970571fxm.23 for ; Wed, 18 Nov 2009 01:53:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:reply-to:in-reply-to :references:from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=x9u1xCWXmL8ACP/s9T0UC2P7OOgyI+zVM/PO2E/rS2I=; b=IO59kUhD2vk4wP9gf8hWgJ/VwBN28bCVz96+yG6loKDNf8U8B91zgHKHBbYB2n2e4W uebCokiIXQhY/COmuzOHy4ula0+Bzmnq9VNMpYP3DzjTg44MRNn6WRkrWO1ZSIDpzoO5 pQIcsusaQuSQltz3lUu0SJrW3305ijinnIpTk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; b=IHHm6GalADFtd549yEtbJd7AFqJG5YSTjSxgWkuTYBaoHgEIAmG4Ma25oE+zgZg8lw vb6M7VLnmtUuMSzMwc7r+UBSRiPn7P4hKdbIItuido1SLzg/B7NgbR+y3keGfWweyZFw hEpUf6sVkEwN4FgOGqL2IjqzfaYlPt4qCdvVs= MIME-Version: 1.0 Received: by 10.223.4.193 with SMTP id 1mr2692567fas.12.1258538006157; Wed, 18 Nov 2009 01:53:26 -0800 (PST) Reply-To: RQuadling@googlemail.com In-Reply-To: <4B01A4C2.8030602@gmx.net> References: <4B01A4C2.8030602@gmx.net> Date: Wed, 18 Nov 2009 09:53:06 +0000 Message-ID: <10845a340911180153g64333917p591dfff925f907fd@mail.gmail.com> To: Christian Seiler Cc: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Closures and $this From: rquadling@googlemail.com (Richard Quadling) 2009/11/16 Christian Seiler : > Hi, > > since a few months have passed since the last discussion on this topic > and perhaps people had time to gather some experience with the current > closure implementation in PHP 5.3 I'd like to restart the debate on > $this in closures and object extension. > > Foreword: The discussion should center on the future behaviour of PHP 6 > ONLY. Whether or not a backport is even possible (binary compability > etc.) or should even be done should be topic of a separate discussion > and should *NOT* influence the decision. The ONLY goal of this > discussion should be to agree on a SANE way of implementing $this for > closures for PHP 6. > > I've updated the original RFC I wrote a tiny bit (I didn't change much): > > > > The basic outline is the following: > > =C2=A0* In the first section I explain the general issue. > =C2=A0* In the second section I show the proposals that were made on > =C2=A0 internals@ before I wrote the RFC. > =C2=A0* In the third section I compare the approaches and explain why > =C2=A0 the approaches (B) and (D) are inconsistent. > =C2=A0* In the fourth section I propose a new approach (bindTo) that > =C2=A0 was only briefly discussed after the original RFC. > > Please read the complete RFC and try to understand the points I'm trying > to make. If something is unclear, *please* ask first. In the past > discussion I had the impression that a lot of people understood only > partial aspects of the problem which made the discussion extremely > noisy. I believe that is a disservice to the issue. However, now we have > the huge advantage of NOT having an immanent deadline for a release. I > hope this will enable a consensus on this issue. > > Discuss away! > > Regards, > Christian > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > I think the consistent mechanism is to have the binding done at runtime and to be explicitly stated by the userland code. $fn =3D function() use() bind($x) { // $this =3D whatever was bound, in this example $x }; so, inside a class... $fn =3D function() use() bind($this) { // $this would be the same as the $this of the class. }; As for public/protected/private ... $fn =3D function() use() bind() access(CLOSURE_PUBLIC | CLOSURE_PROTECTED | CLOSURE_PRIVATE) {}; to control which properties/methods were available. I'd be concerned about that this could be a shortcut to access non-public properties/methods. Richard. ----- Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474= 731 ZOPA : http://uk.zopa.com/member/RQuadling