Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100500 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6511 invoked from network); 10 Sep 2017 11:09:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Sep 2017 11:09:25 -0000 X-Host-Fingerprint: 62.31.75.76 76.75-31-62.static.virginmediabusiness.co.uk Received: from [62.31.75.76] ([62.31.75.76:25288] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 76/5D-10715-46D15B95 for ; Sun, 10 Sep 2017 07:09:24 -0400 Message-ID: <76.5D.10715.46D15B95@pb1.pair.com> To: internals@lists.php.net References: <7B.DB.10715.48405B95@pb1.pair.com> <7cd2884a-6606-4c3f-8f95-776fd277878b@Spark> <14.AC.10715.07215B95@pb1.pair.com> <3b05768a-95b7-42de-8bb8-3d9ce0cce3a5@Spark> In-Reply-To: <3b05768a-95b7-42de-8bb8-3d9ce0cce3a5@Spark> Date: Sun, 10 Sep 2017 12:09:20 +0100 Lines: 1 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="UTF-8"; reply-type=original Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Newsreader: Microsoft Windows Live Mail 16.4.3564.1216 X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3564.1216 X-Posted-By: 62.31.75.76 Subject: Re: [PHP-DEV] Re: [RFC] Match expression From: TonyMarston@hotmail.com ("Tony Marston") wrote in message news:3b05768a-95b7-42de-8bb8-3d9ce0cce3a5@Spark... > >> it makes it impossible to group several conditions with a single break > >In Swift you can group multiple conditions with a comma `,` and in Rust >with a pipe `|`. Here’s how that could look in PHP: > >```php >match ($x) { > 1, 2: ‘One or two’; >} >``` Just because other languages have different ways of implementing certain features is no reason why PHP should include the same implementations. That ius why there are so many different languages - because they do things differently. If they were all the same there would be no need for different languages. >The only thing you cannot do is this: > >```php >switch ($x) { > case 1: > echo “One\n”; > case 2: > echo “Two\n”; > break; >} >``` > >Meaning you cannot “bleed through” the first case into the second, >executing both in case of `$x` being `1`. This is acceptable IMO because >this looks like a bug even if it’s intended. For people who RTFM and know how PHP works that code is perfectly acceptable and not buggy in the least. >> then why can't you use if/elseif instead of making the language more >> complicated? > >Because that’s usually the perfect use case for a switch statement. So why are you proposing a third alternative to the switch of if/elseif statements? -- Tony Marston