Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87985 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42959 invoked from network); 1 Sep 2015 09:08:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Sep 2015 09:08:38 -0000 Authentication-Results: pb1.pair.com header.from=robin@kingsquare.nl; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=robin@kingsquare.nl; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain kingsquare.nl designates 141.138.142.202 as permitted sender) X-PHP-List-Original-Sender: robin@kingsquare.nl X-Host-Fingerprint: 141.138.142.202 spring.kingsquare.nl Linux 2.6 Received: from [141.138.142.202] ([141.138.142.202:48419] helo=spring.kingsquare.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CA/D2-27722-31B65E55 for ; Tue, 01 Sep 2015 05:08:36 -0400 X-No-Relay: not in my network Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com [209.85.217.173]) by spring.kingsquare.nl (Postfix) with ESMTPSA id 73AA1E9C7C7 for ; Tue, 1 Sep 2015 11:08:32 +0200 (CEST) Received: by lbvd4 with SMTP id d4so38765874lbv.3 for ; Tue, 01 Sep 2015 02:08:31 -0700 (PDT) X-Received: by 10.112.162.2 with SMTP id xw2mr12304821lbb.98.1441098511965; Tue, 01 Sep 2015 02:08:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.25.16.164 with HTTP; Tue, 1 Sep 2015 02:08:12 -0700 (PDT) In-Reply-To: References: Date: Tue, 1 Sep 2015 11:08:12 +0200 Message-ID: To: Anthony Ferrara Cc: =?UTF-8?Q?Pavel_Kou=C5=99il?= , Bob Weinand , PHP Internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] [Discussion] Short Closures From: robin@kingsquare.nl ("Kingsquare.nl - Robin Speekenbrink") Dear all, Just to throw in my 2 cents as a userland developer: having multiple ways to write the same thing isnt always right, but does have advantages. (i.e. the [] shorthand is gaining alot of popularity as already noted) (and might even force array() into deprecation imho) But it does also add clutter since a developer has to have _more_ syntax knowledge in order to read the code. In this case, chaining alot of short hand closures would require a bit of a learning curve where the function() syntax is already everywhere... Reading the functions is more self-explanatory... But anyway, with regard to the type hints and such: I saw the [draft] Callable-types RFC ( https://wiki.php.net/rfc/callable-types ) which before this discussion really sparked my interest of having types _everywhere_ (yeeeey!) and with this shorthand closure RFC the two might even get all the FP guys back into PHP ;) In anycase, Anthony, you might want to have a look at the draft RFC, since from a userland view, this seems a really good way to go. Good luck with this development people! Looking forward to whatever comes out of it! Met vriendelijke groet, Robin Speekenbrink Kingsquare BV 2015-09-01 10:44 GMT+02:00 Anthony Ferrara : > Pavel > > On Tue, Sep 1, 2015 at 4:32 AM, Pavel Kou=C5=99il wr= ote: >> On Mon, Aug 31, 2015 at 9:29 PM, Bob Weinand wrote= : >>> I had this RFC in draft since some time, but delayed it due to all the = ongoing PHP 7 discussions. Also we have no master branch to merge features = in until 5.4 EOL. Thus I'm reviving this now. >>> >>> Time for the first RFC targeting PHP 7.1 (assuming PHP 8 isn't going to= be the next version ;-)): >>> >>> The short Closures RFC: >>> https://wiki.php.net/rfc/short_closures >>> >>> Hoping for constructive feedback, >>> Bob >>> -- >>> PHP Internals - PHP Runtime Development Mailing List >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >> >> Hi, >> >> as a purely userland developer, I would definitely appreciate the >> shorthand function for anonymous functions; having tons of stuff like >> "function ($x) { return $x * 2; }" makes the code less readable in >> the end. >> >> I'm not sure about the "auto using" of all variables though; wouldnt >> it be possible to statically check for the used variables and only >> import what's needed, for performance reasons? > > That's precisely what's happening. Not all variables are bound, only > those that are used. Somehow somewhere in this thread the confusion > was implied that the entire scope is copied. > >> Also, how hard would it be to add type hints (only for parameters)? >> Sometimes they are needed to make the IDE know the variable type >> because it can't be guessed automatically. I know about your note in >> RFC,this is just a question to other internal members.Return type can >> be infered by IDEs from the simple expresion quite easily. >> >> PS: would "() ~> foo()" work? I think it should, but I couldn't find a >> mention about it in RFC. :) > > Typing on closures is outside the scope of this RFC. > > With that said, I'd love to hear and see examples of this. It's > something I definitely want to do, just haven't come up with a good > enough way to do it... > > Anthony > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >