Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112543 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 24677 invoked from network); 17 Dec 2020 21:30:12 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Dec 2020 21:30:12 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E3E391804E1 for ; Thu, 17 Dec 2020 13:01:43 -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 out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (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, 17 Dec 2020 13:01:43 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 081255C00AC for ; Thu, 17 Dec 2020 16:01:42 -0500 (EST) Received: from imap26 ([10.202.2.76]) by compute4.internal (MEProxy); Thu, 17 Dec 2020 16:01:42 -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=+FjsnI P8dRVLwUy6InW1lpCfvmk9d86jd8kziBoCZrE=; b=SYL24DDGcKGPq52rfcyBY3 mhf4sxyfzj8N7tltGlFz32LPh3xQV7jkG6Dq5/W6XRh36c3QnaL+T4P+EorcN5v+ 1zjTgHojhoqOxjRQKoZiA3HwTNm+p3IIObbZtQCx0ahlFOn7zQLwZIDKdhgbFxyH FwYgHTPfh9awtFfqU1EHIwDqBqk3ICfjd3Shrg71cPb7lRzxxKN+Nw3LhyuyUOmG TWiHVs36SuX9QSGK7ur99wvQWp3zh2ObBtCY9dX5qU2VMM/pGmd5sJ7ecTchHxhz Sn6fLtG5JYkAwClvv1xi7XVa8q3ctVeHItXRWtEEabEr6VcZmEbc8d9P7JERyeEg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudelgedgudegtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepgeelgfekudeivddvteffueejffdthfejieevhefg ffekudevkedtvdelvddvffefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 66D3514200A2; Thu, 17 Dec 2020 16:01:41 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.1-61-gb52c239-fm-20201210.001-gb52c2396 Mime-Version: 1.0 Message-ID: <490a62fb-f6f4-4d7b-b46d-571abfa28618@www.fastmail.com> In-Reply-To: References: Date: Thu, 17 Dec 2020 15:01:19 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] Short-match From: larry@garfieldtech.com ("Larry Garfield") On Thu, Dec 17, 2020, at 10:23 AM, Sara Golemon wrote: > On Wed, Dec 16, 2020 at 6:50 PM someniatko wrote: > > > > `match` is an expression, where as if-else construction is not. This > > allows for combining it with a potential future feature of single line > > functions and methods. For example (hypothetical syntax is used): > > > > ``` > > $getNumber = fn(int $number) => match { > > $number < 0 => NumberKind::NEGATIVE, > > $number == 0 => NumberKind::ZERO, > > $number > 0 => NumberKind::POSITIVE, > > }; > > ``` > > > > That does read attractively, yes. This is the example that should have > been offered first as it shows the expression nature shining. > > To contrast that with what would be possible now in an expressive > functional form: > > $getNumber = fn(int $number) => [ > -1 => NumberKind::NEGATIVE, > 0 => NumberKind::ZERO, > 1 => NumberKind::POSITIVE, > ][$number <=> 0]; > > The match form *certainly* reads more naturally than the spaceship indexing > form even though both take up equal space. > > -Sara It looks like the quoted part from someniatko changed from a named function to an anon function? Not sure what happened there. I've included both a named and lambda version of his example in the RFC, however, and linked to the short-functions RFC as that would allow the form he originally listed. They complement each other nicely. --Larry Garfield