Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46121 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45764 invoked from network); 20 Nov 2009 07:10:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Nov 2009 07:10:06 -0000 Authentication-Results: pb1.pair.com smtp.mail=crocodile2u@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=crocodile2u@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.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: crocodile2u@gmail.com X-Host-Fingerprint: 209.85.220.227 mail-fx0-f227.google.com Received: from [209.85.220.227] ([209.85.220.227:46662] helo=mail-fx0-f227.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 19/55-04175-DC0460B4 for ; Fri, 20 Nov 2009 02:10:05 -0500 Received: by fxm27 with SMTP id 27so3372777fxm.23 for ; Thu, 19 Nov 2009 23:10:02 -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 :content-transfer-encoding; bh=+WrIX6zMfnFyzfcOzFpN+YPBK94RVrqAc9Aad2wqkDg=; b=tlpYb5GUKUnWupp9a3SFdrX864dKNu/ZPqAhD7IE/zjpbkDz+C9sFNGSsJVnOI1Dtq biGFnSKYS2FV2puI6Xk42WDLqHuVpjQz1xhpwMh4HPT1C5k3tIUECt47aWmxdLIP0UeN cOxXE3NN3Tlci7jGlqB2Uj7ETOnMJC6pe8vPw= 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:content-transfer-encoding; b=isHInW1UmAJ1h+0hyEuXOA4S0/mcFkfHSNVUpgmH3CdMljHIJpOzU3kEHzvBfQB5YC 35dmvB7rq8EORuD/Oj49EoNmoM1KpI69VLJvwQHWmZtwpz07pVBIR/FAkypiNwe68pAt hPEopAK9LVRhdHfz6b8wcsLGEGu4VzV55aNu8= MIME-Version: 1.0 Received: by 10.103.86.34 with SMTP id o34mr450221mul.118.1258701001076; Thu, 19 Nov 2009 23:10:01 -0800 (PST) In-Reply-To: <4B058CFD.9060207@zend.com> References: <4B01A4C2.8030602@gmx.net> <10845a340911180153g64333917p591dfff925f907fd@mail.gmail.com> <4B044070.1010607@zend.com> <4B0469C3.4020503@zend.com> <4B058CFD.9060207@zend.com> Date: Fri, 20 Nov 2009 10:10:01 +0300 Message-ID: To: Stanislav Malyshev Cc: PHP Internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Closures and $this From: crocodile2u@gmail.com (Victor Bolshov) Hi > so you can with $foo->$bar() or $foo() You're talking about variable functions/methods. But that is not the subject of discussion. Variable functions/methods are useful but introduce mess. This is well-known and this feature exists in PHP for a long time - so everybody should be condidered as warned - when they use it. I am talking about $this->methodName() constructions. Currently, in PHP, one can be pretty sure that if this construction works in one place - it should work in another (I mean, methodName() will exist in $this). To be mentioned - I'm not using variable functions here. 2009/11/19 Stanislav Malyshev : > Hi! > >> If php-people really would like rebinding $this, I beleive this should >> be done via method like Closure->bindTo() - to make the fact of >> rebinding clear in the code. >> >> However, there is a problem with rebinding $this - that was not >> mentioned yet, I think. > > This can be a problem, but since PHP is not a compiled language, this > problem already exists - all method names are only checked in runtime > anyway, so it doesn't matter if you rebind the closure or not. Of course, > with rebinding you can easily shoot yourself in the foot by calling > non-existing method - but so you can with $foo->$bar() or $foo() or a num= ber > of other ways. So I think if this construct is expressed in a way that ma= kes > the intent clear (i.e., no implicit rebinding) then it would be OK. > -- > Stanislav Malyshev, Zend Software Architect > stas@zend.com =A0 http://www.zend.com/ > (408)253-8829 =A0 MSN: stas@zend.com > --=20 Regards, Victor