Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98060 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54306 invoked from network); 31 Jan 2017 04:41:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Jan 2017 04:41:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=dave@mudsite.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dave+php@mudsite.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain mudsite.com designates 209.85.213.50 as permitted sender) X-PHP-List-Original-Sender: dave@mudsite.com X-Host-Fingerprint: 209.85.213.50 mail-vk0-f50.google.com Received: from [209.85.213.50] ([209.85.213.50:35858] helo=mail-vk0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 24/7E-51557-B6510985 for ; Mon, 30 Jan 2017 23:41:16 -0500 Received: by mail-vk0-f50.google.com with SMTP id t8so229909554vke.3 for ; Mon, 30 Jan 2017 20:41:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mudsite-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=DKdbBHhB1iw6Nge4z2RdODVSavYaNu1BFzsBGy55LfE=; b=RF/Afu0GYGOd2DkIieBI7nBsyDwk0BVZfKhTwRH77O1YuDUoFpNuTDyxjajEPlsPHM bg48x4vcPFr2JLO/LEisYaWBlszWMbY2BZNQXo4dI/S6fAjdXE9Dp+yOoyBQfgB5GObl HZ4Zr0/dkd6GBM5aWo/Ujk88edLwo2gK4yNIrI8zm11xYH39uuzMPaWAEzltrWlOLnwJ LgnPEieqIqvblnu9J6hjpsHbbb+mXIrBwSKCAoOStCPUm0MgpdQCU4z43qiwb/L7Awxv zROr6YQvjX6WMJGalF6TMont/rxKduMR1g5LgKBIai+kfM3pJhO0HcMk34hB/oINdNB5 /aWQ== 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; bh=DKdbBHhB1iw6Nge4z2RdODVSavYaNu1BFzsBGy55LfE=; b=VlT8m7G7mL1UwzGX1M3FCCZYsQCqXUvFTn5cZJFxv3bC9NSDZ2ApbuuAvPJwGhTWYr ULfz2HwJ1xFt1gKnn/x1mcjYLnW9wJBk2xg7iXqwAP/Y2iDuiC0IzS7na3B3b3YDpMoQ Jt+gl5F8a1ocdy0ywdIWhByDhJnqXBo4XXrDbp/fYnSRHa3Xwt9r/RZnQYPu9wiVprj2 Ge4cYUmbygu1CzCtGCFJhtZ61urAYv3Y+G4rkbMlWa9CaMi7U9d274IHUAe4v7xYSU2P zj+M7199DmnNiUvDt6oqzCbNsQA6lW8ldzSPFyP7jsy3e7Cblnv2pJ+muoPaMFqE5FZg GR0Q== X-Gm-Message-State: AIkVDXIDoau6Sq/LJWRtxhotFLt15jDwpxtR23APjxUzg1OUKHJXX3ebJXsOSCgzg3LU78eYPizxtg7wAE2/3g== X-Received: by 10.31.6.72 with SMTP id 69mr9263562vkg.19.1485837672681; Mon, 30 Jan 2017 20:41:12 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 31 Jan 2017 04:41:01 +0000 Message-ID: To: Andrea Faulds , internals@lists.php.net Content-Type: multipart/alternative; boundary=001a1143dc6caca55305475c8abd Subject: Re: [PHP-DEV] Re: [RFC][Discuss] Arrow Functions From: dave+php@mudsite.com (David Walker) --001a1143dc6caca55305475c8abd Content-Type: text/plain; charset=UTF-8 On Mon, Jan 30, 2017 at 18:12 Andrea Faulds wrote: > Hi Levi, > > Levi Morrison wrote: > > Here is an example of an existing closure: > > > > function ($x) use ($arr) { > > return $arr[$x]; > > } > > > > This RFC proposes syntax and semantics to simplify this common usage to: > > > > fn($x) => $arr[$x] > > > > Is it necessary to introduce a new keyword, fn? > > I think you'd get a similar benefit from: > > function($x) => $arr[$x] > > Likewise, is it necessary to restrict auto-capture to the => syntax? > Couldn't we allow the following? > > function ($x) { > return $arr[$x]; > } > This looks too similar to the current syntax, just ignoring the use() statement. I would add a concurance that => syntax is slightly awkward when used within an array element $a = [ 'func' => fn($x) => Class::method($x), ]; But I'm not overly certain of a different syntax to handle this. I would support expanding to function over fn, to make it more readable/keep the same reserved word. (Although not too certain to the complexity in the parser) Otherwise +1, I like this. -- Dave --001a1143dc6caca55305475c8abd--