Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88411 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60409 invoked from network); 22 Sep 2015 16:01:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Sep 2015 16:01:53 -0000 Authentication-Results: pb1.pair.com header.from=bobwei9@hotmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=bobwei9@hotmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain hotmail.com designates 65.55.111.161 as permitted sender) X-PHP-List-Original-Sender: bobwei9@hotmail.com X-Host-Fingerprint: 65.55.111.161 blu004-omc4s22.hotmail.com Received: from [65.55.111.161] ([65.55.111.161:57177] helo=BLU004-OMC4S22.hotmail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 21/3E-56639-E6B71065 for ; Tue, 22 Sep 2015 12:01:52 -0400 Received: from BLU436-SMTP160 ([65.55.111.137]) by BLU004-OMC4S22.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Tue, 22 Sep 2015 09:01:48 -0700 X-TMN: [kr7XUZpuG0MJvL7vPw9TErJe8zUsC0PB] X-Originating-Email: [bobwei9@hotmail.com] Message-ID: Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) In-Reply-To: Date: Tue, 22 Sep 2015 18:01:43 +0200 CC: Joe Watkins , PHP internals Content-Transfer-Encoding: quoted-printable References: To: Dmitry Stogov X-Mailer: Apple Mail (2.2104) X-OriginalArrivalTime: 22 Sep 2015 16:01:45.0751 (UTC) FILETIME=[FB165270:01D0F54F] Subject: Re: [PHP-DEV] [RFC] [VOTE] Short Closures From: bobwei9@hotmail.com (Bob Weinand) > Am 22.09.2015 um 17:36 schrieb Dmitry Stogov : >=20 > On Tue, Sep 22, 2015 at 4:54 PM, Joe Watkins = wrote: >=20 >> I'd really like to understand what you're trying to say there Dmitry, = but >> I don't get it. >>=20 >> What is your example function trying to show ? >>=20 >> As it mentions in the RFC, vars in short closure are by-value, so I = can't >> see what side effects you might be thinking of ? >>=20 >=20 > It's clear to me that foo() will return NULL, but how many warnings = about > unused variable $y will we get? >=20 > Thanks. Dmitry. >=20 >=20 >>=20 >> Cheers >> Joe >>=20 >> On Tue, Sep 22, 2015 at 9:25 AM, Dmitry Stogov = wrote: >>=20 >>> I'm against the magic - "automatically use () all of the (compiled) >>> variables". >>> I'm also against compound short closures with curly brackets. >>> in my opinion they opens too many ambiguous questions. >>>=20 >>> function foo() { >>> (($x) ~> {$y =3D 3; return $y + $x;})(5); >>> return $y; >>> } >>>=20 >>> also think about nested closures and use of variables from not = direct >>> enclosure. >>>=20 >>> I'm not sure if we need all "functional programming" features in = PHP, but >>> if we introduce them, lets do it consistently with the existing = language. >>> I think, this proposal can't be approved without support for type = hinting. >>>=20 >>> Thanks. Dmitry. >>>=20 >>> On Tue, Sep 22, 2015 at 4:59 AM, Bob Weinand = wrote: >>>=20 >>>> Hey, >>>>=20 >>>> Thanks for all your feedback in the discussion thread! >>>>=20 >>>> So, before I start the vote, just two quick notes: >>>> I've added two notes about the statement syntax and the single = variable >>>> use. >>>> Though a few people complained, I'm not switching to the =3D=3D> = operator, >>> as >>>> I noticed many people expected typehints to work (they don't due to >>> parser >>>> limitations) when they compared to Hack's short Closures. It also >>> allows us >>>> to differ syntax-wise [e.g. for typehints] from Hack without = causing any >>>> confusion later. Which should be the smartest choice: Avoid = conflicts. >>> (If >>>> anyone strongly feels against that, he may vote no, but I would = like to >>> not >>>> bikeshed that in this Vote thread, but leave it free for eventual = actual >>>> issues.) >>>>=20 >>>> Now, the link to the RFC about Short Closures: >>>> https://wiki.php.net/rfc/short_closures >>>> or straight ahead to the vote: >>>> https://wiki.php.net/rfc/short_closures#vote >>>>=20 >>>> Thanks, >>>> Bob Notice: Undefined variable: y in php shell code on line 3 It just yields exactly one notice about the inexistent $y (as it = obviously does not leak through the scope): by-value binding. I'm not sure what your issue here is? Bob=