Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109593 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 31446 invoked from network); 12 Apr 2020 11:27:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Apr 2020 11:27:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DADB71801FD for ; Sun, 12 Apr 2020 02:56:32 -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=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,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 EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073021.outbound.protection.outlook.com [40.92.73.21]) (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, 12 Apr 2020 02:56:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WAO2bcwJed5RxFIjfk0mYSWuL1pzs6kp1fnK23SW1s8vZJO5k8rw8kphCW56a0druqXg4uvigNNOtYC3NVM1kRGA7MOUTL7jv3GsbVYlZDjwIYdhDykrURvtMCIZKKjvR3xyMpbk5xgCKYbvXeqFQwy9sm2R/5Pddh49jauqWIKcKBhYlvT6+GrTQBWeFTgRZX5nYvZq0XtCWn23aBqu7CO1Jwg+LG9xva4cHGBDGFPsZ2z2ZzRILHBnyZHabJ9uvWrK9eSYsJNu5ttKKO4BtuNkPqc/nA9P7o9jr057ERC11yJ/M1CGvQ5YlDNJoEC4unSBXS9+eJtOJlsz3ceE4w== 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=uRqfjRtN36p9A6GjKKC78S7wPq1E6jVa8NaHwFrOrZM=; b=SuuJleAVh88q0ps+rrI2ApV7cxHe46megL9FHZL7o+14m08je/yDUixyabh3ciWK1WXdbe0pyN8o8jXVUBHxrESypjGgpo5CV9yLNRzREp2IL9pvpYBwcJaPblExh0rn+QGwWpa0TxwYSmmRWxwFJcrn66I4iIkqy8ZXxQvZO6QqXr1yZSF+xcukFgCvFt9ZXlJHIRPlgxEU6U2+uYJBs8XSgaJZWLCpq6uF2LOjaaWpEsv87Mbtz8y2l0ce/ugwMYVEESORx7VQoeKCQt0VKyWz9Xmo2BL15qc+3dtd2jTvdlEqwnuDt5s7w+LohXiYQldZjInfE5AjdzgCSk7xhg== 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=uRqfjRtN36p9A6GjKKC78S7wPq1E6jVa8NaHwFrOrZM=; b=ISDtmfyNI+BDWrSpyX44OLvyn6PNzoS9K5tp8UfTYGULwK43b9a4DNmDYWhw0VRpBlK+O6xhViitYQW0kPw0bZeYxBCWjitFzBDb2YW/qYhz25vCYr4ga8vigwfdBYXlyZpo78UgGqdTeqXi0NW2tWKF4GI/yXHurYXY4c72PnkGGd6yWIbhtZsE7Kq3vwgYnrklpAi7dgz9GVeHJz0lFPJh3Nl/jMB01m1jw6nTvscB2/Tum1oIlgUELj29uQ3dApAwJWsqYzRjv0PQtv+PGyrB8SzpP2eXfb0/g8RThNdZaEHmp4s0c5vK+QyfJFOCgLUxn2KyqQ+gARneRR7h0A== Received: from VI1EUR04FT057.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0e::41) by VI1EUR04HT046.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0e::89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.18; Sun, 12 Apr 2020 09:56:29 +0000 Received: from VI1PR08MB2813.eurprd08.prod.outlook.com (2a01:111:e400:7e0e::44) by VI1EUR04FT057.mail.protection.outlook.com (2a01:111:e400:7e0e::274) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.15 via Frontend Transport; Sun, 12 Apr 2020 09:56:29 +0000 Received: from VI1PR08MB2813.eurprd08.prod.outlook.com ([fe80::406a:6628:1bf0:4d24]) by VI1PR08MB2813.eurprd08.prod.outlook.com ([fe80::406a:6628:1bf0:4d24%7]) with mapi id 15.20.2900.026; Sun, 12 Apr 2020 09:56:29 +0000 To: Ilija Tovilo , php internals Thread-Topic: [PHP-DEV] [DISCUSSION] Match expression Thread-Index: AQHWEF+nZG5U35iOAE6gUQQi9rmkvqh1PESG Date: Sun, 12 Apr 2020 09:56:29 +0000 Message-ID: References: In-Reply-To: Accept-Language: es-ES, en-US Content-Language: es-ES X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:DD2DD7B0730F2E7B1D9B3AE79F5A1A5AA0DF873C46519C1ADA8A0865CF0E5116;UpperCasedChecksum:6D02B132AD601B7EF80D23DCF5D0C5CCEA33470BF686956EB12EECF60A51679C;SizeAsReceived:6959;Count:45 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [n4b8KSKC4S/nLQ95cY4IyESXPwo3pULZ] x-ms-publictraffictype: Email x-incomingheadercount: 45 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 2d5f020b-456f-45be-f147-08d7dec7c610 x-ms-traffictypediagnostic: VI1EUR04HT046: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: C/M/N5iH42Er2UPYu1UFl54cmiMDjGJjMRbnji4E2A0X3HD3oJi4bqCRZ+Tq4OehJ9Dz/PptFracHPt2RjVLDJ0S6sfLQNf3DvzbpyWuOoN1Q9lc0WAz6NeDpN86OtA6bYXrPzY/IokJgcnK1IxtrUttfLhtPj99njDyx1e5on8YuNrIJMp9u/CKwFlVTxeZvEIfE2lWCi3yC7MuwPEGzQIc2DjwlXa3/INg4Jfqk+s= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR08MB2813.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; x-ms-exchange-antispam-messagedata: spK/riCL9LR1PRtoH60UWMXINVWe92i4sg1NIU7KpYMvXs2zsKf9/t0hSIhNPlfmCbk6p3H054fToCJpoxIpTKmfeZ7C1mUR3VBMtO3BFQaUaDFsCoa1np2+DhZdn+0CpdrSB2eAjhZiu9gkZBcCLA== x-ms-exchange-transport-forked: True Content-Type: multipart/alternative; boundary="_000_VI1PR08MB2813513D859F91441C020848B8DC0VI1PR08MB2813eurp_" MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 2d5f020b-456f-45be-f147-08d7dec7c610 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Apr 2020 09:56:29.8811 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1EUR04HT046 Subject: Re: [PHP-DEV] [DISCUSSION] Match expression From: txigreman@hotmail.com (=?Windows-1252?Q?Iv=E1n_Arias?=) --_000_VI1PR08MB2813513D859F91441C020848B8DC0VI1PR08MB2813eurp_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable > Hi internals > > I'd like to announce the match expression RFC that replaces the switch > expression RFC I announced a few weeks ago. > New: https://wiki.php.net/rfc/match_expression > Old: https://wiki.php.net/rfc/switch_expression > > Due to the feedback I decided to take the RFC in a slightly different > direction. The main objections were: > > 1. It didn't behave like the traditional switch so it shouldn't use > the switch keyword > 2. It didn't fix type coercion > 3. The RFC was poorly structured > > In hindsight I understand why I had a hard time writing the RFC. I > tried making a case against the switch statement while really not > addressing the switch statement at all. The new RFC proposes a match > expression that fixes all the objections raised against the switch > statement. Additionally, match arms can now contain statement lists > which allows you to use the match expression anywhere the switch > statement would have been used previously. > > While some people have suggested statement lists aren't necessary I > don't think it makes sense to raise objections against the switch > statement without offering an alternative. > > I also experimented with pattern matching but decided against it. The > exact reason is described in the RFC. > > I'm now confident this is the right approach. I hope you will be > happier with this proposal. > > Happy Easter! Hello Ilija, I really like much more this new approach. Only a pair of questions: Would be posible for blocks to require a return statement instead of raisin= g an error? $y =3D match($x) { 0 =3D> =91a=92, 1 =3D> { foo(); return 'b=92; // OK } 2 =3D> { var(); } // Error, return statement is required } Would be feasible for the fallthrought problem to use =93continue=94 when y= ou really want to chain =93cases=94? match ($x) { 0 =3D> { // Only for 0 continue; // Same as omitting a break in a traditional switch }, 1 =3D> { // Same for 0 and 1 } } Regards, Iv=E1n Arias. --_000_VI1PR08MB2813513D859F91441C020848B8DC0VI1PR08MB2813eurp_--