Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112187 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 41944 invoked from network); 5 Nov 2020 16:59:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Nov 2020 16:59:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9A0E01804D8 for ; Thu, 5 Nov 2020 08:20:39 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 5 Nov 2020 08:20:38 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id D9FAEF52 for ; Thu, 5 Nov 2020 11:20:37 -0500 (EST) Received: from imap26 ([10.202.2.76]) by compute4.internal (MEProxy); Thu, 05 Nov 2020 11:20:37 -0500 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=fm1; bh=htyVoW IikEpaz5SRAo9nd4od3DKdySLqWN2nDMgqL5U=; b=mMK/3uLzw+yNcwXhFjVpM6 jH2OF764Gmt22XniVyxrVuYuI+/5QCa+heTd5cx4DiRXMH9BOnb2acQWR1YtI/kA 5N3I1oJ9zHuYMDZHsGlm/0J6uGkoIgcUHk46Jvfw4pBIyGUWBoctiP0MnSpcoleG D9X9oSMCaovL1WdWlU4E66N+FN2j3RPlFkBPasAhr15Mto5ttpNCkr0lfqdwkIxj avHpCEClb1YE0u7G2ycmXrV8Kd+hXUsBdFNqDb0xFcCUESZ+qDvUTLailRNQPgOC yQQr4X6BCkvCheG6JceUyOawjEUHQfitiDJtJBMaAh98nV7yuOAoT25ew22coa9w == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddtjedgkeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpedvgfekgfduhffhjeeufeefgffhgfejvefgfeekkeek hfeluefgteejheekgefhveenucffohhmrghinhepghhithhhuhgsrdgtohhmpdhphhhprd hnvghtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhep lhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 03CFB14200A2; Thu, 5 Nov 2020 11:20:37 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.0-565-g5179928-fm-20201104.001-g5179928e Mime-Version: 1.0 Message-ID: In-Reply-To: References: <3af046e2-2647-4b9a-907e-47c2043ad60f@www.fastmail.com> Date: Thu, 05 Nov 2020 10:20:16 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] Short-function syntax From: larry@garfieldtech.com ("Larry Garfield") On Wed, Nov 4, 2020, at 4:05 PM, Nuno Maduro wrote: > Hey Larry, > > In my vision, this proposal is a good addition to PHP exactly as stated in > this pull request (https://github.com/php/php-src/pull/6221): where only > the "=> expr;" is introduced, and not the "fn". > > For visual consistency in the future of PHP functions/methods, I think it's > important to differ "=> expr;" from "fn": > > - "=> expr;" means "arrow": syntax that defines functions/methods with > one-line return expressions. > - "fn" means "short": syntax that makes functions inherit scope. It's > already in use by arrow short closures ( > https://wiki.php.net/rfc/arrow_functions_v2 ). > > Therefore, from my understanding, your proposal would allow all the > following things to be possible: > ```php > // arrow function > function foo() => /** */; > > // arrow closure > $foo = function () => /** */; > > // fn/short arrow closure ( already introduced in PHP 7.4 ) > $foo = fn() => /** */; > > class Foo { > // arrow method > poublic function bar() => /** */; > } > ``` > > If this proposal keeps using the "function", and not the "fn", I don't see > any conflict with my Proposal (multi-line short closures - > https://github.com/php/php-src/pull/6246). > > Good luck with the RFC. > > - Nuno Yes, that's how it would fall out, assuming multi-line-arrows happen. I'm honestly still torn on that myself for various reasons, but "=> means expression, fn means auto-capture, use one or both as appropriate" seems like a reasonable syntax guideline that we can teach people. --Larry Garfield