Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104713 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 39513 invoked from network); 14 Mar 2019 17:21:51 -0000 Received: from unknown (HELO mail-yw1-f68.google.com) (209.85.161.68) by pb1.pair.com with SMTP; 14 Mar 2019 17:21:51 -0000 Received: by mail-yw1-f68.google.com with SMTP id e76so4494533ywa.9 for ; Thu, 14 Mar 2019 07:12:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9V/fzSQjGiYuY1nCPxmbHnFfEFlcRl227fCPDvCq7Eo=; b=uQaoH3Em6Iqa9P7/EgCLYStW4FcxRWAY/E5wk7M8o+FgWDKWrKZS7C//fi78oUqK9P nysdy3qOZdoqWlyuRwGdG1sWiDWR3vuTtfF6V8S5jiLNxg1PQrDnGS3ljfq1l/cHqKBO CUmfxdR9JfIbnbTwgEITUNLPIJ/tXQQ+lwZuje7tRMQgdV6zih1n6EDs3L7xo+yBF+tU sYxCgDIV9RSae76bcpyDGqbcNX+HWHO2iC22LW3NhZs6bxCvICXAtrLiKEfCRaFyY0eo MJwMxBh6D+RZMmyEqhUHIDhjS7IyzfklED4ga2askTGjErO4OWNsDbf5fD1pWNuw7CkL 6qTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9V/fzSQjGiYuY1nCPxmbHnFfEFlcRl227fCPDvCq7Eo=; b=QJmiXedFkgmlN4CP/F/cYl0qf+Q/rSVyH1f+cb7dtMazMoDzaQ/03eEzRFQVmKWx89 68JGN2nUTSN8WGPOvu4nrwALsPMp62VKlfA96exWAS2nbc4wE/k2Hl83GNffT6dcKMvS L9Hj1JrZJhpi9TniOBK8h93K3Y1kAqa1V2AKe1zTMV3PQ4+XxnwrozPznOvw+8vLgt2h 5XwpWbIkWk7oBWSCcUlkdCdjF5bpmlY+1UD2QLfywBBnyaL7jUDK5DRNEqFvbxzO0Hrv GMMcmYoKTHsR27lHRSZsnU/sp6EZ2YnKwujMjfeKkGESc7eHlfqjYVVDRRQJksTJqB2H gzXA== X-Gm-Message-State: APjAAAVGQfCusqiOOu4wo9xtnmMB0BfA49xn3Cq651Nozs5i3lxhGFF7 fC31JiEyytUxegO4UdnmKEyPm+I3EPUjyY0a01c= X-Google-Smtp-Source: APXvYqwE9YnqwualXyK3NBET/p+vM437S9Uia1Sh1DvnntSYfDQl7DPYo4XmvyoQkasMBJkzmwRKm2eUplihGgz7sQw= X-Received: by 2002:a25:764e:: with SMTP id r75mr32551061ybc.317.1552572734971; Thu, 14 Mar 2019 07:12:14 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 14 Mar 2019 15:12:03 +0100 Message-ID: To: Rowan Collins Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000005b25d505840e826a" Subject: Re: [PHP-DEV] [RFC] Arrow functions / short closures From: benjamin.morel@gmail.com (Benjamin Morel) --0000000000005b25d505840e826a Content-Type: text/plain; charset="UTF-8" This makes me thinking, has this syntax been considered? ($x) => { $x * $y } Nested: ($x) => { ($y) => { $x * $y } } AFAICS, we don't need the brackets around the whole expression, as this should be parsable without any ambiguity; and the syntax would be closer to that of JavaScript. On Thu, 14 Mar 2019 at 14:44, Rowan Collins wrote: > On 13 March 2019 15:56:40 GMT+00:00, Nikita Popov > wrote: > >Motivated by the recent list comprehensions RFC, I think it's time we > >took > >another look at short closures: > > > >https://wiki.php.net/rfc/arrow_functions_v2 > > Hi Nikita, > > Thanks for reviving this. I think the RFC does a great job of > justifying both the syntax and the behaviour, and focusing on the most > used features without ruling out further additions in future. In > particular, I think whether and how we support auto-capture in full > function bodies has its own pros and cons to debate, separate from > auto-capture as a convenience in short "lambda" expressions. > > I was initially quite drawn to a block-style syntax. As someone not > particularly familiar with functional programming (which I suspect > puts me in the majority of PHP users), I actually find it easier to > spot this as "a closure returning a closure": > > { ($x) => { ($y) => $x * $y } } > > rather than having to work out the associativity of chained operators: > > fn($x) => fn($y) => $x * $y > > However, I imagine the only people who will heavily use such a > construct will be those who *are* familiar with functional programming > in other languages, and will find the simpler syntax more familiar and > convenient. > > It would also be ugly to add full block bodies in a similar style like > { ($x) => { ... } }, and while I'm not convinced we need that, we > probably don't want to rule it out completely. > > As such, I support the RFC in its current form. > > Regards, > -- > Rowan Collins > [IMSoP] > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --0000000000005b25d505840e826a--