Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112529 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 72509 invoked from network); 16 Dec 2020 17:22:55 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Dec 2020 17:22:55 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E94811804BE for ; Wed, 16 Dec 2020 08:54:05 -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.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 16 Dec 2020 08:54:05 -0800 (PST) Received: by mail-qk1-f169.google.com with SMTP id 19so23171993qkm.8 for ; Wed, 16 Dec 2020 08:54:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=YG/0qsE/N8xTD4hJk0CvIMg14B+OoBCpi65UDZPh08Y=; b=SrFUWV4B0xQXVkpzP+OiFzTE/adbLNyDjUosfjclBUvXXA/k6BvrLHKzoLF49jb2pB t5OcKEEpUtFfdYHBOOtInoTbX/I52Vepl4n9GXiB2V7JNjkqmth16EEQa3a5DdK8mIgR 4k8POtGpAmTn5nFPNuJJ1r0AUDApn1BzLTNOIOLKEFfYZRk3J9rdMC6GS03noIaM/CjQ cOENnBm5zAxDRlP+Bkz9Txh6fe/4QCMeSyBWb8rdgF6aLJdnNrITSGOevDksF4VO2KUD tTW+hS943iv+ggH+mDL4asykElM8OhYqJSe78PBvS/mWYBW5FKUeqoYbPb0kRmBS/EY+ a8eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=YG/0qsE/N8xTD4hJk0CvIMg14B+OoBCpi65UDZPh08Y=; b=VthdcAyRNV1RAtFwEvpeOL8AnZwnWJGcjfmxDW1XOr6BV+LQkckFhtyGwji9f8+JWW A29Iyfqa85qtIQinRvS+G6IMnlZIxwEi6mfQfWfN2JFcMt6dR+1y3gnGr2vIXxCjyBH5 bGmugX/l37qwn+WSXtNejO61OfXTguilnPHxmiKKeEbmZEixV3b7hG0xrQBJKcI24r3o yABSz5q558VFMTsYslryLPuZkMXv3z+6Tz7PYOC5vjkUnYU0LaZZC3bLq1g4C779P9e/ BH5kA1uE8hJHzwSvZzIYaHBGtvM1gWGJnA0ygCuFOwLW+8yu0lhet+AuIFFZVccPjnpv HUvw== X-Gm-Message-State: AOAM530cvTbcKnGPVf8Rd6sloVxp+K4E+yogfy6P+0XnYBvxTxJH9K6I t20wsXDTk6SnC4oOGSOElN580A== X-Google-Smtp-Source: ABdhPJwbVgA9Z66UJJcFZIeuVsGGhPoJgrh9OktnGIaiB4hTBhW/3LKk4YQT3c1Mn83gL1F6u8ZC2w== X-Received: by 2002:a37:9c16:: with SMTP id f22mr44796489qke.67.1608137644401; Wed, 16 Dec 2020 08:54:04 -0800 (PST) Received: from [192.168.1.236] (c-24-98-254-8.hsd1.ga.comcast.net. [24.98.254.8]) by smtp.gmail.com with ESMTPSA id q37sm1292392qte.10.2020.12.16.08.54.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Dec 2020 08:54:03 -0800 (PST) Message-ID: <19FFF24D-3B1E-40FA-B836-9229E95416EE@newclarity.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_6BB776CC-150C-4720-8D8B-AA6E5FD67FF3" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Date: Wed, 16 Dec 2020 11:54:02 -0500 In-Reply-To: Cc: php internals To: Larry Garfield References: X-Mailer: Apple Mail (2.3608.120.23.2.4) Subject: Re: [PHP-DEV] [RFC] Short-match From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_6BB776CC-150C-4720-8D8B-AA6E5FD67FF3 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On Dec 15, 2020, at 12:18 PM, Larry Garfield = wrote: >=20 > On Tue, Dec 15, 2020, at 3:00 AM, Nikita Popov wrote: >> On Mon, Dec 14, 2020 at 6:34 PM Larry Garfield = >> wrote: >>=20 >>> 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. >>>=20 >>> https://wiki.php.net/rfc/short-match >>>=20 >>> -- >>> Larry Garfield >>> larry@garfieldtech.com >>>=20 >>=20 >> 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 =3D=3D=3D" comparison. If it = is omitted, >> a reasonable person might think that >>=20 >> match { >> preg_match(...) =3D> ... >> } >>=20 >> 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. >>=20 >> Of course, with "match {" being a dedicated syntax, we could make it = a >> TypeError to use a non-bool match arm... >>=20 >> Regards, >> Nikita >=20 > 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! >=20 > 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. Allowing "switch {...}" to represent "switch (true){...}" might not = actually be consistent. Since switch/case does a loose equality check = some people get confused when using it with booleans:=20 = https://stackoverflow.com/questions/8829229/why-switchtrue-in-php-with-a-s= trange-logic = If we allow "switch {...}" to represent "switch (true){...}" then the = value switch compares will be hidden and less obvious to a developer if = they are forgetting to consider switch's evaluation behavior. For some = people this would increase the WTF factor. #fwiw -Mike P.S. OTOH allowing "while(true){...}" to be represented as "while{...}" = would be great since AFAIK "while{...}" would not violate the principle = of least surprise. --Apple-Mail=_6BB776CC-150C-4720-8D8B-AA6E5FD67FF3--