Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111402 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 61644 invoked from network); 9 Aug 2020 20:11:19 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Aug 2020 20:11:19 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CEB77180509 for ; Sun, 9 Aug 2020 12:10:16 -0700 (PDT) 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.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10olkn2013.outbound.protection.outlook.com [40.92.42.13]) (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 ; Sun, 9 Aug 2020 12:10:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mPLUq+TJB2fpumLGJKQoezq8X8R3qD3NWphepxGbcWNQ6GsOsjRfc6oWoH9SkY/feJKaoz/uwJ8g+GwUlil2QUNeFjLlHgge2qx44hWdQG7Fq+Xu1BD3LALsFQaAZDlDu8VW1Zosx5rGFQ/3+eU8rjIHawmtfzEoohPVOqaDmWV4vLRBCs/EBB6qU64UgPjVTi4PuELFR20Hxq+HQz1Swsf4LlfrEt4bxojGMoMRH+qAwM+apMACwqqGWLAvUoLH2Or7IiBybM1S3gj68lPLJbxtYsu7e2AuGxWdEP2pKKH9qLbff3GNCtbw/1xMl0QopBRrdAXmY6R0xbsv0byacw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lW1mqKeRO0vDlFA1lie96OIc4+fgc/aFrA+4p9q9Sek=; b=il+6qo78QqhpJmhYHZnFGJgxrt+X5Lem+ceGsQiJpHvHYGGBTzDZ9tbyOwW7SJUBpzRNLhFq6PsZ/VSrN+do/c8P5t5LBoUQTCNTjZCWHuL4dSemV2w3Ds/3xf3iP7rd/VNRgGpLUE+YLJL9QVUjgxyjS+zO035UItdCMd+vBrGOj4GVSgoo0NONQVnlkuELkwSfyUHncgaPVaTBYpyGDcBQ2r/cBuTObOELDsZOR61WQAoj0L6MMwk8SMmYMLNf9pnfVebRSW2mz5CNFG5jENn7gRIlvCutgSSIv4wYQ0mNS9DE8A8R/qpsfYa6GBDJ325wSwp9mtO5Gq7tVKsiEA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lW1mqKeRO0vDlFA1lie96OIc4+fgc/aFrA+4p9q9Sek=; b=bV9mzorI7EA/kOUDbHQppcyA7FEJr04VHIomdwugtwfKumhkyr3rweXYW3GsgcU7X/TGvu6f/w2uBsMm0AI1ecbV4ZEv288/yggEj1eaxWHX3IYS9h/YZyW25r2Jxuss0tk1K3Jo5Sw/mLo5KjzZYfAGQcLNzO0uuxB/RN8g7YZSAPRVaCAyt5Ld2Yjp0+YvLs6NdE834YvxjZNpaQQ17CxyYpGnkJRwmJAUYilTzkLHxSxmjxgO1vuJtlIx5oL6MJJ5tyGbEkvddyOmTjWBZ+xzmbkT9o/cJgGcdl6rP4CyOrmXCf7jNVsFmWP0KWXXhTfV0q896r8TII//WD078g== Received: from BN7NAM10FT065.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::46) by BN7NAM10HT049.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::323) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.16; Sun, 9 Aug 2020 19:10:14 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7e8f::46) by BN7NAM10FT065.mail.protection.outlook.com (2a01:111:e400:7e8f::157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.16 via Frontend Transport; Sun, 9 Aug 2020 19:10:14 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::cc10:a3e2:1dcf:adc1]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::cc10:a3e2:1dcf:adc1%6]) with mapi id 15.20.3261.022; Sun, 9 Aug 2020 19:10:13 +0000 To: "internals@lists.php.net" Thread-Topic: Allow dropping (true) from match expression conditions in 8.1 Thread-Index: AQHWbn2Ozv6Nwx7o0UW9HKWL6piDRg== Date: Sun, 9 Aug 2020 19:10:13 +0000 Message-ID: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:6A80F75ADC4EC0B486DFBFC175FE20781EF127F5002AF2F4D8C83359AF75F9B3;UpperCasedChecksum:EE836C30D8ABA6D9551A32E6CC3BA87D6CDF5121DA9BD6CCC62ED5DA98F82AA0;SizeAsReceived:6851;Count:41 x-tmn: [U0aVTOlV/UhIbhCZ1MASPk/PJCO7w++LpZXBwuHws2n0HcMFs1R+vWvmRItDtMgB] x-ms-publictraffictype: Email x-incomingheadercount: 41 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: eab46d2e-0fe3-4626-3792-08d83c97d84a x-ms-traffictypediagnostic: BN7NAM10HT049: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: qqgCZQIdAc9kcCQ/JROQ0S0kGlh9ExQlWxVYothqra1MIAbF5KhY5PxUzWqtVCP9b4jQcN4FtTV+imrDP4TMHb9uiLe6VUwfbwXKJmY9yonFkRVV7c4W/EwuWfGDOujeTzNCDf4MB+5q+KZkN+EOI8np6xqV6od0Nipi9TPUg/PnImITzvVu1aEcrpCwuKyT6oD7ky/KvGUE0OqWuM9BsaZN4EXxiSBZ0Sq5C0vAfS0CVrwjY2aurlkArscp8+fU x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR07MB6618.namprd07.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; x-ms-exchange-antispam-messagedata: 3KT0G1M0disG1L3nHj5CaYKrMaNOjdmWPVqc0QfVxSLA+P+tJ7UO58vIZVw6AMUtEp5SjsHYQYJ77xD+q/JETPG+vjbU+vorYt2rY/g1sdaVj+5YCPRM4j4zYp9v8jRt6/MFPeo1cYxv7mQV8gPsYktVE2cVfSahe6mdzVvxE7+8p3oic15V+ryQptpzw+1IM9HmnGS/aLVvMoMeEKDxEg== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: BN7NAM10FT065.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: eab46d2e-0fe3-4626-3792-08d83c97d84a X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Aug 2020 19:10:13.8326 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7NAM10HT049 Subject: Allow dropping (true) from match expression conditions in 8.1 From: tysonandre775@hotmail.com (tyson andre) Hi internals,=0A= =0A= https://wiki.php.net/rfc/match_expression_v2#allow_dropping_true=0A= mentioned this in the future scope.=0A= =0A= ```=0A= $result =3D match { ... };=0A= // Equivalent to=0A= $result =3D match (true) { ... };=0A= ```=0A= =0A= https://externals.io/message/110243#110292 summarizes the current status=0A= =0A= > 80% were in favor of this feature but it's also worth noting that only=0A= > 20 people have voted. To avoid risking another rejection and thus the=0A= > RFC being delayed for a year I'd rather move the feature to a=0A= > different RFC. Also, the feature being included in the first draft was=0A= > a rash decision in the first place (completely my fault). There are=0A= > multiple ways to deal with the value comparison (e.g. do type coercion=0A= > like the switch or type-error on a non-boolean value) but they haven't=0A= > been discussed at all.=0A= =0A= I'm not the RFC author, but discussing alternatives was brought up 2 months= ago.=0A= I'm in favor of strict equality, but would be fine with loose equality.=0A= =0A= Personally, I feel like adding a type error on a non-boolean value would be= inconsistent=0A= with the short-circuiting behavior I'd expect from match.=0A= Additionally, if the first conditions are almost always true,=0A= this would make bugs in the last conditions harder to find.=0A= =0A= People might intuitively expect `match {` and `match(true) {` to do the sam= e thing=0A= when refactoring code, and be surprised if loose comparison cast behavior i= ntroduces bugs after a refactoring=0A= (e.g. `match { $arrayOrBool =3D> ..., default =3D> process_array_or_false()= }`)=0A= - Maybe adding a loose comparison equivalent for `match=3D=3D{}` or `match~= {}` or something (both with and without an expression) would help.=0A= I can see use cases for it but I'm not sure what others think or if it'd= be worth the language complexity (e.g. already possible to cast arm condit= ions to booleans)=0A= (e.g. dealing with user input that may be an int or stringified int from= db/user input/a remote API call)=0A= =0A= Thanks,=0A= - Tyson=