Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97319 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70121 invoked from network); 7 Dec 2016 09:58:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Dec 2016 09:58:40 -0000 Authentication-Results: pb1.pair.com smtp.mail=michal@brzuchalski.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=michal@brzuchalski.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain brzuchalski.com designates 188.165.245.118 as permitted sender) X-PHP-List-Original-Sender: michal@brzuchalski.com X-Host-Fingerprint: 188.165.245.118 ns220893.ip-188-165-245.eu Received: from [188.165.245.118] ([188.165.245.118:57737] helo=poczta.brzuchalski.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 24/99-11772-B4DD7485 for ; Wed, 07 Dec 2016 04:58:37 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by poczta.brzuchalski.com (Postfix) with ESMTP id 0AF76298423F for ; Wed, 7 Dec 2016 10:58:33 +0100 (CET) Received: from poczta.brzuchalski.com ([127.0.0.1]) by localhost (poczta.brzuchalski.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3f1hstOgreZN for ; Wed, 7 Dec 2016 10:58:29 +0100 (CET) Received: from mail-wj0-f175.google.com (unknown [209.85.210.175]) by poczta.brzuchalski.com (Postfix) with ESMTPSA id 7C32C298423C for ; Wed, 7 Dec 2016 10:58:29 +0100 (CET) Received: by mail-wj0-f175.google.com with SMTP id xy5so355581098wjc.0 for ; Wed, 07 Dec 2016 01:58:29 -0800 (PST) X-Gm-Message-State: AKaTC01SKt29Fnahay53HMzMqJa4PgiTJONUjpfouMQ24n24/rdkjJU5eFVq0g2SdTgV2tI3tckNJ8BKPAm0/Q== X-Received: by 10.194.243.231 with SMTP id xb7mr67524931wjc.60.1481104709225; Wed, 07 Dec 2016 01:58:29 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.153.205 with HTTP; Wed, 7 Dec 2016 01:58:28 -0800 (PST) In-Reply-To: References: <5726130C.9030708@telia.com> Date: Wed, 7 Dec 2016 10:58:28 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Wes Cc: Joe Watkins , PHP internals , Nikita Popov Content-Type: multipart/alternative; boundary=089e01493e6411999e05430e90f6 Subject: Re: Fwd: [PHP-DEV] RFC: Anonymous Class Lexical Scope From: michal@brzuchalski.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=) --089e01493e6411999e05430e90f6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Wes, How about magic `$parent` variable accessed in classes which are declared inside other classes? Why `$parent`? I was thinking of it in case of inner classes also, I've got some concept about it https://brzuchalski.com/blog/inner-classes-in-php-concept and think therre might such variable be usefull too. This concept is similar to anonymous classes in way that both may be declared inside other class. Cheers, Micha=C5=82 Brzuchalski 2016-12-07 10:51 GMT+01:00 Wes : > One important thing I'd like to have here is importing the "outer" $this. > e.g.: > > public function bar(){ > return new class use($this as $that){ > public function test(){ > return $this->that; > } > }; > } > > And I dislike how this would look with NikiC's proposal: > > return new class{ > private $that =3D $this; > }; > > Especially because "constant expressions" could change in the future and > allow operations with $this, eg: > > An option could be what Joe proposed `new class use($this as $that)` (whi= ch > I would particularly like if it allowed any kind of expression `new class > use($this->foo->baz() + 10 as $that){}`) > > Or introduce a scope resolution keyword that works similarly to `parent::= `. > E.g.: > > public function bar(){ > $foo =3D $this->getFoo(); > return new class{ > private $that =3D outer::$this; > private $foo =3D outer::$foo; > private $fooCall =3D outer::$this->getFoo(); > }; > } > > Thoughts? > > > 2016-05-01 16:30 GMT+02:00 Bj=C3=B6rn Larsson = : > > > Hi, > > > > Nice and clear-cut RFC! One reflection is if the usage of use > > to "import" variables could have an impact on a proposal > > for a short form of Lambda functions in the future? > > > > Cheers //Bj=C3=B6rn > > > > PS I liked the Short Closure RFC btw. > > > > > > Den 2016-04-26 kl. 10:25, skrev Joe Watkins: > > > >> Morning internals, > >> > >> Just to be clear, the implementation is now in good shape, the > >> discussion may continue. > >> > >> Attached is message from a confused contributor ... sorry about th= e > >> confusion :) > >> > >> Cheers > >> Joe > >> > >> ---------- Forwarded message ---------- > >> From: Yasuo Ohgaki > >> Date: Tue, Apr 26, 2016 at 9:13 AM > >> Subject: Re: [PHP-DEV] RFC: Anonymous Class Lexical Scope > >> To: Joe Watkins > >> > >> > >> Hi Joe, > >> > >> Since you seem to pause this RFC activity for now, I'm sending this > >> mail only to you. > >> > >> On Wed, Apr 20, 2016 at 3:01 PM, Joe Watkins > >> wrote: > >> > >>> I must say that of all the suggestions made so far for syntax, I stil= l > >>> prefer use(). > >>> > >> I strongly support "use()". > >> It's the way PHP imports other scope variables :) > >> > >> Regards, > >> > >> -- > >> Yasuo Ohgaki > >> yohgaki@ohgaki.net > >> > >> > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > --=20 regards / pozdrawiam, -- Micha=C5=82 Brzuchalski about.me/brzuchal brzuchalski.com --089e01493e6411999e05430e90f6--