Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87980 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34458 invoked from network); 1 Sep 2015 08:44:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Sep 2015 08:44:09 -0000 Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.47 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.215.47 mail-la0-f47.google.com Received: from [209.85.215.47] ([209.85.215.47:34821] helo=mail-la0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 37/11-27722-65565E55 for ; Tue, 01 Sep 2015 04:44:07 -0400 Received: by lanb10 with SMTP id b10so52528808lan.2 for ; Tue, 01 Sep 2015 01:44:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=4U8iUcauB5XoC/HJUOYWDZAOwwzeVJLe70b/+o92F0E=; b=lg/XdwQx+zauVTwRmyq+1htsHYgQDbF8vBnKDefTuqAzw2vBVWmPSKa9gMOzgjbM1J fFtNm81cVBGcGrgs/jwJmWHxg5BIKs+dSmmxWylVKYGcEkwqoE7gDcqlZUct3k7BpX9z ziEl8H4yE/uL9TkXv5huFVgHnbk/yz6puZM6A7a0c/543cJdEvl7BUtvqUc52q1TzxY2 9nsoblb4qIb8tkzkMmDXxiYUYNVb3aXszpe+i0zPkp+aX2ypqIPhm3xQdZR3+5nvDW/3 LUuPTFaSBzb2AqmmrAQEykZDIpracZxPynMCaZI9iXdxFnPb6/iObqF6vScPZcxgg+AU 7/2g== MIME-Version: 1.0 X-Received: by 10.112.11.163 with SMTP id r3mr12712011lbb.45.1441097044160; Tue, 01 Sep 2015 01:44:04 -0700 (PDT) Received: by 10.25.141.131 with HTTP; Tue, 1 Sep 2015 01:44:04 -0700 (PDT) In-Reply-To: References: Date: Tue, 1 Sep 2015 04:44:04 -0400 Message-ID: To: =?UTF-8?Q?Pavel_Kou=C5=99il?= Cc: 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: ircmaxell@gmail.com (Anthony Ferrara) Pavel On Tue, Sep 1, 2015 at 4:32 AM, Pavel Kou=C5=99il wrot= e: > 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 o= ngoing PHP 7 discussions. Also we have no master branch to merge features i= n 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