Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112515 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 56147 invoked from network); 15 Dec 2020 17:48:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Dec 2020 17:48:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 78EFF1804C6 for ; Tue, 15 Dec 2020 09:19:27 -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=-1.2 required=5.0 tests=BAYES_05,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 out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (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 ; Tue, 15 Dec 2020 09:19:26 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id F1E645C007C for ; Tue, 15 Dec 2020 12:19:25 -0500 (EST) Received: from imap26 ([10.202.2.76]) by compute4.internal (MEProxy); Tue, 15 Dec 2020 12:19:25 -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=rNtnax aVCPSXmQE6NV3oQ3KReXOtKbvB0HILnqEcj2k=; b=PIB1XuxWyCoBzPgasqVZqD q9zfzQlK3OmG5KJKHJW59I1wK8uQFMgfVilrDstm8jVZTd57SroLleRasEe9PLPq a6EqwtZBuhMp+gOTIHoGR1klJ7X5JAzz68BLUbuM7a7Rh0qvDsglyArTXC/J6dhq CHSJ6AQ0PwYOv5hLIZDpJ2QfpS5ofvpRzcTjjWPangK04SYlmCIdPtAZZPSnGo+U f8Oy1hjCSUYvqdv15EbHhjzfzRvqW8MRbSFTud6w/aCbY4RyjWwq9T17or+y/0oW y/239j7TGD3txDQqLljT2POPsgPB6CYZMIKA/GqrSDbQR4Oov6iBMui3DHcyesSA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudeltddguddtudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepveehhedvveejledvvefgleevffdtjeekledvkeeg heffgfeivdejhffhledtudetnecuffhomhgrihhnpehphhhprdhnvghtnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhf ihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 6028B14200A2; Tue, 15 Dec 2020 12:19:25 -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: In-Reply-To: References: Date: Tue, 15 Dec 2020 11:18:55 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] Short-match From: larry@garfieldtech.com ("Larry Garfield") On Tue, Dec 15, 2020, at 3:00 AM, Nikita Popov wrote: > On Mon, Dec 14, 2020 at 6:34 PM Larry Garfield > wrote: > > > I present to Internals this tiny RFC to follow up on the match() > > expression RFC from earlier in the year. There was solidly positive > > support for this shortcut previously but it was removed for simplicity at > > the time, with the intent to bring it back later. It's now later. > > > > https://wiki.php.net/rfc/short-match > > > > -- > > Larry Garfield > > larry@garfieldtech.com > > > > Just like Sara, I'm not strongly opposed to this, but I'm also not sure > this is worthwhile. Writing "match (true) {" instead of "match {" is not > particularly tedious when compared to the size of the remaining structure. > Writing "match (true) {" has the advantage of being more explicit about > what this actually does, namely a "true ===" comparison. If it is omitted, > a reasonable person might think that > > match { > preg_match(...) => ... > } > > is going to do something sensible, like it would if placed inside an > "if()". But it does not, as preg_match() returns 1, not true, and as such > the match arm will never be taken. This is more obvious when the value that > is being compared against is explicitly given. > > Of course, with "match {" being a dedicated syntax, we could make it a > TypeError to use a non-bool match arm... > > Regards, > Nikita Hm. preg_match() is the first example I've seen that makes me think the weak comparison may have value in this case. I will have to consider that and discuss with Ilija a bit. (Since match was his addition and relates to the ongoing enum work.) I'd also have to figure out how best to handle that, too, since it's a deeper change. Whee! Several people have mentioned also short-circuiting switch the same way. I am not opposed, and honestly don't feel too strongly about it either way. On Twitter, someone suggested also short circuiting while (true) the same way; I don't know how useful that is, but I acknowledge the consistency argument. I'm happy with whatever the consensus is on both points. --Larry Garfield