Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100496 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96824 invoked from network); 10 Sep 2017 09:23:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Sep 2017 09:23:17 -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:17186] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7B/DB-10715-48405B95 for ; Sun, 10 Sep 2017 05:23:17 -0400 Message-ID: <7B.DB.10715.48405B95@pb1.pair.com> To: internals@lists.php.net References: In-Reply-To: Date: Sun, 10 Sep 2017 10:23:12 +0100 Lines: 2 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: [RFC] Match expression From: TonyMarston@hotmail.com ("Tony Marston") wrote in message news:eb28362c-4f8f-45df-bbf0-582e8ad2b8af@Spark... > >Hi everybody! > >Has this idea been discussed before? > >I find myself writing switch statements in PHP quite rarely. This has a few >reasons: > >1. It doesn’t have a "strict_types” version >2. It is quite verbose (lots of breaks) >3. It is a statement rather than an expression > >Often, if / elseif statements turn out to be shorter, safer and easier to >read than the switch statement. >What I’d really love is something like a match expression: > If there are circumstances where a series of if / elseif statements turn out to be shorter, safer and easier to read than a switch statement, then the intelligent thing to do would be to use if / elseif statements instead of trying to make the switch statement more complicated. If your problem with the switch statement is that you sometimes forget to insert a break statement then that is your fault. Try to use the language features as they were intended to be used and not how you would personally like to use them. Millions of other programmers have no problem with the switch statement, and they would not be pleased to have it changed just to deal with your perceived problem with it. -- Tony Marston