Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:55739 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72461 invoked from network); 7 Oct 2011 19:32:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Oct 2011 19:32:29 -0000 Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.170 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.160.170 mail-gy0-f170.google.com Received: from [209.85.160.170] ([209.85.160.170:49950] helo=mail-gy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DD/01-00384-BC35F8E4 for ; Fri, 07 Oct 2011 15:32:28 -0400 Received: by gyb11 with SMTP id 11so4475096gyb.29 for ; Fri, 07 Oct 2011 12:32:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=OSWsPDYQgowyweJICNgTueW38f1GOydfW5vuy3exWpo=; b=k5VcDJJOTdsEClvZx+KWV6lqehZ2RaMY658G1L6QzRBTgAjwZb6zboC0R/RSxicT50 c5R8DuN+4cyESsLCqnGHumMf89OWjG8i5Ajs8XxmEXs8YU8V4nnvrV5q/Nig+Czj7WvH YVmdFjXTb4R9kSmn+Gu+2XDfypF3IPVLViYKE= MIME-Version: 1.0 Received: by 10.236.185.4 with SMTP id t4mr12347095yhm.121.1318015944657; Fri, 07 Oct 2011 12:32:24 -0700 (PDT) Received: by 10.147.125.13 with HTTP; Fri, 7 Oct 2011 12:32:24 -0700 (PDT) In-Reply-To: References: <4E5B24DD.10903@sugarcrm.com> <4E671355.5060908@sugarcrm.com> Date: Fri, 7 Oct 2011 21:32:24 +0200 Message-ID: To: Gustavo Lopes Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] 5.4 beta From: tyra3l@gmail.com (Ferenc Kovacs) ' On Fri, Oct 7, 2011 at 8:58 PM, Gustavo Lopes wrot= e: > On Fri, 07 Oct 2011 18:31:42 +0100, Ferenc Kovacs wrot= e: > >> do we have a wiki/documentation about what exactly ended up in 5.4 >> from the Closure improvements? (Rebind) >> >> https://wiki.php.net/rfc/closures/object-extension#privateprotected_memb= ers_scope >> is really hard to read, as it contains all of the suggested ideas and >> possible solutions, etc. >> if not, maybe someone with the required knowledge =C2=A0could start work= ing >> on adding the documentation? >> > > I don't think so, but if I had to summarize the innovations in 5.4, this > would be it: > > - Closures can now have an associated scope > - Closures can now have a bound object > - Closures can now be either static or non-static > > - Closures defined in a place with an active scope are scoped accordingly > - Closures defined inside an instance method (or bound closure) have a bo= und > object (namely $this) > - Closures are static if defined within a static method or with the stati= c > keyword (static function() { ... }) > > static =3D> !bound > (but it's false that !static =3D> bound) > bound =3D> scoped > !static && scoped =3D> bound > (i.e., if !static, scoped <=3D> bound) > > The bound instance and the scoped can be freely changed with Closure::bin= d > and $closure->bindTo, subject to these constraints. "- Closures can now have an associated scope" as it is https://wiki.php.net/rfc/closures/object-extension#privateprotecte= d_members_scope ? at first I thought that scope means Variable scope, but I think I get it now: it means that when the Closure calls/access something through $this, it will be handled as it was called/accessed from the given class(scope). and this also explains why we had to add the third param for Closure::bind. the bound param defines what is the $this pointing to, and the scope means that from what scope would be used for accessing the $this. having a static Closure means that it won't have the $this, but it can still have a scope (so it can interact with other static methods). thanks, I think I managed to wrap my head around that! --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu