Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105273 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 65602 invoked from network); 14 Apr 2019 19:54:11 -0000 Received: from unknown (HELO mail-it1-f194.google.com) (209.85.166.194) by pb1.pair.com with SMTP; 14 Apr 2019 19:54:11 -0000 Received: by mail-it1-f194.google.com with SMTP id k64so23139257itb.5 for ; Sun, 14 Apr 2019 09:52:22 -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; bh=pdO0uY71xUIn7FBmgZ0v/HP/Li0h2d0EzT3+4P4gWfU=; b=eRUBrHnvjkLnbJaa9kYl1ayfeD1WEaBTRNlos7o+TBfKKqNfvykGim0sAiyLeNu405 417x4yFSgkVDJFJK5czy+51V7moYRPLwRc/VUi5DlDesSMQrOscu6glGNg4PmxNly0O/ 62hMMOsZw2CoDvADs3NzAKv7G58s5s0mX0LEJ7pZxknTCN+SVw5mKQVXDBIP4mQ496uI rG3btM+F6W1BoMvA1LPFDBWMHh03tBK1MShPdEN3McobAyfoHhgZT4VC4indK3saTJdG qeyqwF/7sMXinJ7B6X3eMxr5nt2/DXntQxTYsBxwZaWwr7PPmRZF/QHLrd2z+Wi5PySQ 6FDw== 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=pdO0uY71xUIn7FBmgZ0v/HP/Li0h2d0EzT3+4P4gWfU=; b=rHydN7Gv7OBXOLD5YVhq6ntk1A+y4DrvTYJJehYTYeXze4qttyHPMcP3aeYe76xDCS S2KRU1QbMyCAtD3yGlpk0JSE54N74K4lJrr4XBID2UfymPegf/nFAqX7a+X1iW8ppS5W KYMmCoB/6Y5d+X66z8iEQ1RGOYOvv5iDtNAS7FZCnDkbRwGkPeOzFq0+ZEN+7GKS/rRi QHiepoy8Z1cQgmzS62DNfsYpXJXP7Bi1onY6nbGe28pZtT+GLqfUePmFM0Cpb29xz1dH 2Ycc8WDRPlsb8iBfY/VLjoaMtJ+npfDE+8KevIbgNMMU4IkULn2eiZPBj9fV8SjAD5Jl 4Aaw== X-Gm-Message-State: APjAAAXSdNFUAcHm7BYmAKlfz+4ye2uJX/3mk/3KX7jhdhZHfQmWtDy5 Ma3KIbDrk9chHQikmGubC3w0nezw6pdy22gql4tcuxdVrbQ= X-Google-Smtp-Source: APXvYqx9fmpjejEp23JIbs3F53uDlK0lKWlVmOJ5ZF4IFm0fehVE3nhwkxpBWAll4SN1EuDrFYwysILtEBcVq56Tgls= X-Received: by 2002:a24:56d1:: with SMTP id o200mr21275709itb.111.1555260742072; Sun, 14 Apr 2019 09:52:22 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 14 Apr 2019 18:52:04 +0200 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="0000000000001080700586805c5c" Subject: Re: [RFC] Arrow functions / short closures From: nikita.ppv@gmail.com (Nikita Popov) --0000000000001080700586805c5c Content-Type: text/plain; charset="UTF-8" On Mon, Apr 8, 2019 at 4:06 PM Nikita Popov wrote: > On Wed, Mar 13, 2019 at 4:56 PM Nikita Popov wrote: > >> Hi internals, >> >> 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 >> >> This is based on a previous (withdrawn) proposal by Levi & Bob. It uses >> the syntax >> >> fn($x) => $x * $multiplier >> >> and implicit by-value variable binding. This example is roughly >> equivalent to: >> >> function($x) use($multiplier) { return $x * $multiplier; } >> >> The RFC contains a detailed discussion of syntax choices and binding >> modes. >> >> Regards, >> Nikita >> > > Heads up: I plan to start voting on this RFC tomorrow if nothing new comes > up. > > Most of the discussion was (as expected) about the choice of syntax. > Ultimately I think there are many reasonable choices we can make here, but > we should stick to a specific proposal for the purposes of the RFC vote. > None of the given arguments convinced me that some other syntax is > *strictly* better than the proposed fn($x, $y) => $x*$y -- it's more a > matter of some choices being slightly better in one case and slightly worse > in another. My personal runner-up would be \($x, $y) => $x*$y, but I > suspect that there are some people who are more strongly biased against > "sigil salad" than I am... > > Nikita > So, there's been quite a bit of extra discussion here... unfortunately I can't say that it really clarified anything, we're still circling around different syntax choices, with the main contenders being fn, \ and ==>. fn($x) => $x fn($x, $y) => $x*$y \$x => $x \($x, $y) => $x*$y $x ==> $x ($x, $y) ==> $x*$y I think the main qualities of these possibilities are: * Implementation complexity: fn and \ are easy, ==> is hard (lexer hack). * Availability of reduced syntax: \ an ==> have a special single-argument syntax, fn doesn't. * Obviousness/readability: fn and ==> are obvious, while \ is not. Especially \$x => $x looks quite obscure to the uninitiated (is that a variable escape, like it would be in strings?) At this point I'm considering to either a) move forward with fn() as the choice I'd consider most likely to gather a consensus or b) have a secondary three-way vote between these three syntax choices. Nikita --0000000000001080700586805c5c--