Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109877 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 70471 invoked from network); 28 Apr 2020 16:37:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 28 Apr 2020 16:37:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 64663180551 for ; Tue, 28 Apr 2020 08:10:37 -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-ASN: AS8075 40.64.0.0/10 X-Spam-Virus: No X-Envelope-From: Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2077.outbound.protection.outlook.com [40.92.91.77]) (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, 28 Apr 2020 08:10:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UrVF9kH6TWes1/hxl5ZCQ+QLFouF+cIMRbpMIZTySDk7lwFLtkzDBpPORaVqf/vlYbSVJIoSFXNSa3U7jkmDXkU4k7hTL5n9c6/bcEcP7ubs5kFrepS7w4vmLBy9uXAOU27lpT3R87iFCJLAe9zPuHph1AxdgwptiLlhwCVvbx/ClBD6W6B5hkoboQJXJNCNlZRZ/EcDxGEyyNLftAaa8gluqgE+AJYHP1gHlyTSM7z7aGNMPVwdYt+kiQui6gS5CMK/Rnb4V7XG/6VDH9sKT/STyuadBZmiCTIlEPGlNf4N4o7MaJCu4kmzWY3JTGz1Vq7d9vc9WzcNRkw7hogfAA== 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=24R/PcJIzjBgm1qH9y1p7BP58mm8p+h4BpVUhBVjELA=; b=PRm9a2wHMPeSAyd8e8EXV6qXm/WCtyKDBVgoCiWdK4tI8PdWpdKBE0B8MCHWg3Inh43S2QxY3xIMHekZo5mMWCMsWCveid4D88tV0+zNcpYi1uMdoO6j0cJheJ9GhAC/4WeXpBt9dhtt8Od/q5RydSe51miiQBEGoYtKMWoLsMHmpRteiBaE18D/fhBP1c/EGX8UPVcrJobd3Zx0WAc0BdD7uITOdcr4U8ArPtNaztMzZSoSuHR32xVciGcmw7QdT/PJ0HpQ/58h+QHEbz0dkFKuO+WP7XKOf8E1n//JlBLGNhotHRTYsav26xYZ7/3E/X1qDYUSK29gJBcfeuHwAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hotmail.com; dmarc=pass action=none header.from=hotmail.com; dkim=pass header.d=hotmail.com; 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=24R/PcJIzjBgm1qH9y1p7BP58mm8p+h4BpVUhBVjELA=; b=j4PwEnoIUr5n7pIk+0z4DL9LEkkVDvvDnztmf95VWUIxq2lxnaaa+Ksgb1NeHEVX/o+1Ly7jcW3AvJGCwHzx/UBaIS2Ix2M2ctzAj7/PAurO8HSZqFBgb6Mp2Wja5qW25eyj+eVjob1sD4dXR/mxiBE23c5k/BIUpFqLhR0CSMfD70BpAf7W7XNQKmXPaa0N1NycUMsMzieRlklzbKfE+hAPQc/o/lLyAUx85I/CSnJRvgH00V24MwEmZ9/4CBFn8sdDJjR87yAo8gudinrt7PejC2JSh4u56euX+YXPxa6Ghdo29Or0nSli/Z9bN3caKJrG2FdjNUOpZIKge+9r+w== Received: from DB8EUR05FT011.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc0f::40) by DB8EUR05HT249.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc0f::205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.15; Tue, 28 Apr 2020 15:10:34 +0000 Received: from VI1PR02MB4703.eurprd02.prod.outlook.com (2a01:111:e400:fc0f::4e) by DB8EUR05FT011.mail.protection.outlook.com (2a01:111:e400:fc0f::114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.15 via Frontend Transport; Tue, 28 Apr 2020 15:10:34 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:30B0E66EC5E611C73F59FE579631EC64D82E70C5F71D4BFC121AAEC44BB0DEBB;UpperCasedChecksum:9C43A59F9AF13AC2DF9801B56FED4187B6AA2FE788A4FC6FA104A4FC56519201;SizeAsReceived:8140;Count:50 Received: from VI1PR02MB4703.eurprd02.prod.outlook.com ([fe80::61d8:9f5e:4baf:492d]) by VI1PR02MB4703.eurprd02.prod.outlook.com ([fe80::61d8:9f5e:4baf:492d%7]) with mapi id 15.20.2937.023; Tue, 28 Apr 2020 15:10:34 +0000 Content-Type: text/plain; charset=us-ascii In-Reply-To: Date: Tue, 28 Apr 2020 17:10:31 +0200 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <5ea6e4b0.1c69fb81.cf3ee.2bbfSMTPIN_ADDED_MISSING@mx.google.com> To: Rowan Tommins X-Mailer: Apple Mail (2.3445.104.11) X-ClientProxiedBy: PR3P189CA0054.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:53::29) To VI1PR02MB4703.eurprd02.prod.outlook.com (2603:10a6:803:8f::13) X-Microsoft-Original-Message-ID: <0A91B1AC-E2BF-43A6-ADDE-553126203F9F@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [IPv6:2001:7e8:cba2:c100:78d2:e537:51c:ef45] (2001:7e8:cba2:c100:78d2:e537:51c:ef45) by PR3P189CA0054.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:53::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.13 via Frontend Transport; Tue, 28 Apr 2020 15:10:34 +0000 X-Mailer: Apple Mail (2.3445.104.11) X-Microsoft-Original-Message-ID: <0A91B1AC-E2BF-43A6-ADDE-553126203F9F@hotmail.com> X-TMN: [yjYljTWpV2BdFEWu2rXHarmRk1uPQwg06ZQoXTymognNwdpvl1UGGlr+hd15kIDU] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 62efd221-55f7-493a-609f-08d7eb864cb7 X-MS-TrafficTypeDiagnostic: DB8EUR05HT249: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jNkmPiF+FcDNqKzE8h0U0+pUC6b1G4kHzHgY1stVN++JLj0np06eqvC2O/muPhfnCmlH8lHgNlAA89KOi4XgIRc1Q7i8Xfn67eTgJ1qq3nFUuxMioEBew4jwBfO83Y2GNFyj6Ds/wQP93R/fw3n0punB1uWvP1T5WHWPpqkPOUaeFjZyP9be0J+bZatRTO6o16omuW/PcQe+RF33wdlWCQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR02MB4703.eurprd02.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; X-MS-Exchange-AntiSpam-MessageData: rlWfWC8ueZHiLoywUgvrLgBG/+dOlk1OCJjRudc4liJEMPFKYTWz7kQ7dgu6gxudifWZBym/tu7zAi1Q/4wtsZzK3W1Z+AkanP1dvxo4fXE+85GyvTmFJ5XRhL2Se8Myj6Z+PrK0PlGrhLAYd/HWD1Q1oFC/iICRYKJTdxRXWTpjXVJJqbCbXCS6aOg6R8ML4vlLo3Er70fk2wV6Tn7ovQ== X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-Network-Message-Id: 62efd221-55f7-493a-609f-08d7eb864cb7 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2020 15:10:34.8052 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8EUR05HT249 Subject: Re: [PHP-DEV] [VOTE] match expression From: bobwei9@hotmail.com (Bob Weinand) > Am 28.04.2020 um 12:48 schrieb Rowan Tommins : >=20 > On Tue, 28 Apr 2020 at 11:19, Ilija Tovilo wrote= : >=20 >>> for the control-flow statement, it feels awkward and not in >>> keeping with the rest of the language. If they were separate proposals, >> the >>> statement would probably end up looking very different. >>=20 >> Can you elaborate? If I made a proposal exclusively for match >> statements the syntax would be exactly equivalent. >>=20 >=20 >=20 > If we take away the expression part, the proposal would be to replace thi= s > switch statement: >=20 > switch ( $expr ) { > case 1: > case 2: > statement; > break; > default: > statement; > break; > } >=20 > With this match statement: >=20 > match ( $expr ) { > 1, 2 =3D> { > statement; > }, > default =3D> { > statement; > }, > } >=20 > The extra set of {} inside looks a little odd, but is a reasonable way to > remove the implicit fallthrough. However, the other changes seem to just = be > arbitrarily new syntax: >=20 > * No "case" keyword > * =3D> instead of : > * commas between statement blocks >=20 > If the motivation is simply to fix the current switch statement, why not > keep the syntax more familiar? >=20 > match ( $expr ) { > case 1, 2: { > statement; > } > default: { > statement; > } > } >=20 > The colon looks unnecessary next to the opening brace, but if we keep it, > the braces could be optional like they are in an if statement: >=20 > match ( $expr ) { > case 1, 2: statement; > default: statement; > } >=20 > Note that this wouldn't suffer the problems of accidentally running code > that you get with one-line if statements, because the following could > simply be a syntax error: >=20 > match ( $expr ) { > case 1, 2: statement; anotherStatement; > default: statement; > } >=20 >=20 > That syntax doesn't lend itself as well to being used as an expression, b= ut > I'm not convinced making one syntax work for both use cases is the right > goal given the compromises it requires. >=20 >=20 > Regards, > --=20 > Rowan Tommins > [IMSoP] Hey Rowan, I think you should first think about why the "case" needs to exists at all.= In particular it exists to distinguish goto labels from the case expressio= ns in switch. With match, match restricting statements (and thus goto label= s) into { brackets }, it now is not necessary to do such a distinction and = we can get rid of the extra token. "=3D>" is logical as well, we use the return value of the expressions (see = fn() and array syntax), the colon is exclusively used for pure statement bo= undaries. The comma is necessary for the expression syntax at least (consider match($= a) { 1 =3D> 2 + 2 + 2 =3D> 3 } - is this now match($a) { 1 =3D> 2, (2 + 2)= =3D> 3 } or match ($a) { 1 =3D> (2 + 2), +2 =3D> 3 } ?) You may argue to m= ake it optional behind a statement block though. Bob=