Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98150 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98823 invoked from network); 3 Feb 2017 22:41:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Feb 2017 22:41:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 77.244.243.86 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 77.244.243.86 mx105.easyname.com Received: from [77.244.243.86] ([77.244.243.86:37542] helo=mx105.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 25/B8-38491-A0705985 for ; Fri, 03 Feb 2017 17:41:15 -0500 Received: from cable-81-173-135-7.netcologne.de ([81.173.135.7] helo=[192.168.178.20]) by mx.easyname.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1cZmXW-0001qd-3l; Fri, 03 Feb 2017 22:41:11 +0000 Reply-To: internals@lists.php.net References: <19.45.38491.677D4985@pb1.pair.com> To: Michael Morris , internals Message-ID: Date: Fri, 3 Feb 2017 23:41:07 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-DNSBL-PBLSPAMHAUS: YES Subject: Re: [PHP-DEV] Re: [RFC][Discuss] Arrow Functions From: php@fleshgrinder.com (Fleshgrinder) On 2/3/2017 11:26 PM, Michael Morris wrote: > On Fri, Feb 3, 2017 at 3:37 PM, Niklas Keller wrote: >> >> >> There are more drawbacks to that syntax like no parameters looking pretty >> weird: || => >> >> > I can't think of a valid example of an arrow function without any arguments > at all. These functions are very simple iterators to plug into things like > array_map. If you can think of one please post it. > There are many situations where one might want a closure that takes no arguments. ``` $option->unwrapOrThrow(|| => new Exception('my message')); ``` Creating a supplier callable is often less resource intensive than actually computing the supplied value. Rust has exactly that syntax but it can become rather cryptic and PHP is a verbose language in general. I think that it is best for PHP to go for `function` to keep things nicely aligned and to avoid problems with union types (which we really need). -- Richard "Fleshgrinder" Fussenegger