Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46091 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30517 invoked from network); 18 Nov 2009 21:24:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Nov 2009 21:24:00 -0000 Authentication-Results: pb1.pair.com header.from=chrisstocktonaz@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=chrisstocktonaz@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.222.176 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: chrisstocktonaz@gmail.com X-Host-Fingerprint: 209.85.222.176 mail-pz0-f176.google.com Received: from [209.85.222.176] ([209.85.222.176:36105] helo=mail-pz0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7C/45-16241-EE5640B4 for ; Wed, 18 Nov 2009 16:23:59 -0500 Received: by pzk6 with SMTP id 6so1033434pzk.29 for ; Wed, 18 Nov 2009 13:23:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=MkXE1HWaOcIUiIbfhhKYdKz/Ypjr+n5oAietBvNifHg=; b=v+Tg0EUuPzgPDgrPvm6gL121N+GaspYumTS9hv3iZ3DZ8STNqYd6yc4XkXaQ3n0H0C VVEffB/A/PVKtGsH/qiuNcwhAbFvFPiI5f8C8F2jPbM8DU9Mx6lvP0WKTSi15GBSkVRF dPZh2M4SRARa2CStBYd4uWp5+jK1ezUAQdEQA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=qgaxCUO23AAxJwFbVToMRZNsRcP1iThRX9yIsjFW3luM+L/8wfxNk0bDl9IEuLFiAx AGGQqNv2RvNR/bcQIT67TId0aluhSmNCMtB/UnZhGXR3tX8clSThO7J/7h/C1b+F35N2 TH6d9lXu03wh9Y+Kf1a+mfjbt6baHbGuENtbM= MIME-Version: 1.0 Received: by 10.142.247.38 with SMTP id u38mr1334530wfh.349.1258579435540; Wed, 18 Nov 2009 13:23:55 -0800 (PST) In-Reply-To: <4B044070.1010607@zend.com> References: <4B01A4C2.8030602@gmx.net> <10845a340911180153g64333917p591dfff925f907fd@mail.gmail.com> <4B044070.1010607@zend.com> Date: Wed, 18 Nov 2009 14:23:55 -0700 Message-ID: To: Stanislav Malyshev Cc: RQuadling@googlemail.com, internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Closures and $this From: chrisstocktonaz@gmail.com (Chris Stockton) Hello, On Wed, Nov 18, 2009 at 11:44 AM, Stanislav Malyshev wrote: > I have very hard time imagining somebody that would be comfortable using > such a construct. What happened to keeping it simple? And why every tiniest > feature of every remotest imaginable use case has to be brought into the > language syntax? That syntax made my eyes hurt, but I think really the problem is that people want to dynamically add methods with $this in the closure pointing the the object it has been attached too. Really I like A. but can see cases for rebinding (C). Maybe a magic method like __attach(string methodName, function method) that would rebind $this in closures would be a solution. But it would be the first magic method I can think of that isn't overridden by the defining class. $o = new StdClass; $o->bar = 'bar'; $o->__attach('foo', function() { echo $this->bar; }); $o->foo(); // bar Just a thought. -Chris