Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:76676 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24445 invoked from network); 19 Aug 2014 02:30:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Aug 2014 02:30:24 -0000 Received: from [127.0.0.1] ([127.0.0.1:3534]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id 68/71-14556-FB6B2F35 for ; Mon, 18 Aug 2014 22:30:23 -0400 Authentication-Results: pb1.pair.com header.from=thegreatall@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=thegreatall@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.181 as permitted sender) X-PHP-List-Original-Sender: thegreatall@gmail.com X-Host-Fingerprint: 209.85.214.181 mail-ob0-f181.google.com Received: from [209.85.214.181] ([209.85.214.181:39045] helo=mail-ob0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F3/71-14556-CA4B2F35 for ; Mon, 18 Aug 2014 22:21:33 -0400 Received: by mail-ob0-f181.google.com with SMTP id va2so4720098obc.12 for ; Mon, 18 Aug 2014 19:21:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=PtLbTH5zqwXGyk6seQ2n0vz6r0AKAIZYqdTZY4nsFF4=; b=iWHlbG6o8l89/Q6cO7ToxMEOu6RR4MlAUI0YErUCqu2fwzNsNxWEeM+k8Peznb62d+ cA4u/XiYaZ71hfynqC5xnZL3oqygyiFY9tS9hZQB+6oFm0wYpSXL9wd0Cwfb7skJNWIr qKk8KVtCXO+8ZQPZiX9xM5RQDZZD1WIMdtbZIh+oXI0ISQDSJ0uedI/r4nvN0i6RinPC dO/EtXN19+8xLSeZWSDK0J36yy9PutANrMGhZ9mqE0F0Hfk4NDNW6YPonMfk8UbbwxnG e+XB9KNYq+t8KQobQweZpHBTZgJKDql4BhMGCfC9uiGJ+fsm3uWdxgxTC4Q7StH7w1Ya dsOQ== MIME-Version: 1.0 X-Received: by 10.182.104.104 with SMTP id gd8mr39570831obb.17.1408414890022; Mon, 18 Aug 2014 19:21:30 -0700 (PDT) Sender: thegreatall@gmail.com Received: by 10.76.109.170 with HTTP; Mon, 18 Aug 2014 19:21:29 -0700 (PDT) In-Reply-To: <8DC84B14-42BB-466D-B07A-03ADB68EFA34@ajf.me> References: <235C617B-25E1-4185-A784-38EF1D7BFFDC@ajf.me> <38FC0B11-5E15-43E9-8467-347359970D46@ajf.me> <53F1372B.9080207@sugarcrm.com> <8DC84B14-42BB-466D-B07A-03ADB68EFA34@ajf.me> Date: Mon, 18 Aug 2014 21:21:29 -0500 X-Google-Sender-Auth: YmrzuslBaH7UWJ-cwn2-EwGFQPY Message-ID: To: Andrea Faulds Cc: Levi Morrison , Stas Malyshev , PHP internals Content-Type: multipart/alternative; boundary=089e01160bf8375f2c0500f22501 Subject: Re: [PHP-DEV] [VOTE][RFC] Closure::call() From: nathan.bruer@starin.biz (Nathan) --089e01160bf8375f2c0500f22501 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I will +1 this as I have had to deal with some of these struggles, as a suggestion though: "Like the bind(To) methods, a static class cannot be bound (using =E2=86=92= call will fail)" I would like to see this function work like Closure::bind()/Closure::bindTo() and give the option for the $newScope option. > why would you need a closure that is not static, > but is not bound to any object? I think I can answer this, I wrote a project which allows for "hooks" to be installed in areas of the code. I made it so each [static] method has a "before" and "after" which may be tied to it. This allows for things like: "beforeUpdate()" or "afterUpdate" or "afterCreate" exc... The framework handled the installation and execution of all hooks that a dev may have wished to install. If a method like this was available it would use much less resources and be faster in theory because the PHP engine would not need to create an entirely new object/closure every time I wished to execute the method. Simple example of what I spoke of above: https://gist.github.com/allada/b7e880104e3a7eb13a63 Notice how you don't need to create an entirely new object just to call a method inside a scope. This allows a dev to make their closure have access to $this just as if it was installed inside the function it's hooking into. On Mon, Aug 18, 2014 at 7:04 PM, Andrea Faulds wrote: > > On 18 Aug 2014, at 00:40, Levi Morrison wrote: > > > On Sun, Aug 17, 2014 at 5:13 PM, Stas Malyshev > wrote: > >> Hi! > >> > >>> It does, but maybe you missed it. Under the Proposal section: > >>> > >>>> To solve this, we relax the current invariant of scoped closures > >>>> having to be bound, and add a new parameter to bind(To) to produce > >>>> an unbound, scoped closure, like so: > >> > >> Indeed, I missed it - I was looking for bindTo. I think it should be > >> made more prominent, and I'm not sure what closure that is not static, > >> but does not have a bound object, means. What happens if you call it? = It > >> sounds a bit strange concept - why would you need a closure that is no= t > >> static, but is not bound to any object? > > > > Hence the vote was cancelled while it is reworked. > > To clarify: The RFC has been reworked now, I actually changed the RFC and > patch just before I cancelled the vote. Review appreciated before vote is > reopened. > > -- > Andrea Faulds > http://ajf.me/ > > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --089e01160bf8375f2c0500f22501--