Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105312 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 95858 invoked from network); 17 Apr 2019 17:15:55 -0000 Received: from unknown (HELO wout4-smtp.messagingengine.com) (64.147.123.20) by pb1.pair.com with SMTP; 17 Apr 2019 17:15:55 -0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 1A81D38F for ; Wed, 17 Apr 2019 10:14:49 -0400 (EDT) Received: from imap26 ([10.202.2.76]) by compute7.internal (MEProxy); Wed, 17 Apr 2019 10:14:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=Mr/aYO iwm0eQxWvR1XYj4DuA1A95DTSH9QgkmlL23Ms=; b=jOtVXZI5RfPMFTE7NWimRN Xqvjs9VxnVGAdb4Fa1u2inJOFr0hyUt2r+eeGvNybEBNzlsYKP3SLTBbKOpf4iMA L3IzXN/EfZeBu5m3laRZ1IqCMKTV8jOyFPR9TxcYw4jJb5a3ZLbvzkn+u5Z07l10 +LfLmWoN9hRJRNtcgMFZLk9TPyBpHhtIWmMZ/3B0PfxYN9StWCgPj1HFsyBKysN+ oYQu1ZhYY2XhCiNdOD3MGGrZmbuu6/rXrXYXhb44wYAL/kYOf36D+o+92VvvR4S6 /iZM5G47/DUVJMRpfwUIAJ8hHKPCsl2VJ2qgtoYhDUZpRAaNgxZx+zyHzXD6Pgtw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrfeefgdejfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgesthdtre dtreertdenucfhrhhomhepfdfnrghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhies ghgrrhhfihgvlhguthgvtghhrdgtohhmqeenucfrrghrrghmpehmrghilhhfrhhomheplh grrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmnecuvehluhhsthgvrhfuihiivgep td X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 606F9B47A1; Wed, 17 Apr 2019 10:14:48 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.6-443-g918f9d3-fmstable-20190416v3 Mime-Version: 1.0 X-Me-Personality: 10727885 Message-ID: <3b6337b3-7a0c-470c-b648-7e04866f7833@www.fastmail.com> In-Reply-To: References: Date: Wed, 17 Apr 2019 10:14:47 -0400 To: internals@lists.php.net Content-Type: text/plain Subject: Re: [PHP-DEV] Re: [RFC] Arrow functions / short closures From: larry@garfieldtech.com ("Larry Garfield") On Sun, Apr 14, 2019, at 11:52 AM, Nikita Popov wrote: > 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 I was under the impression from your earlier comments that ==> made the lexer too unhappy to even consider. Is that not the case? From a usability POV, I think ==> has the edge; it's reasonably self-documenting and has a short-circuit version that is still highly readable and not confusing. It also fits the "think of it as an expression not a function call" mindset, which is important. The only downside is the implementation complexity. I think you have final call on whether that would be too-ugly implementation-wise. If it doesn't make the lexer too unhappy ==> is my preference, I think. \$x I'd probably get used to, even if it is a bit ugly. fn() is the "safe" option: Most verbose but keeps the lexer happy. --Larry Garfield