Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100497 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99179 invoked from network); 10 Sep 2017 09:44:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Sep 2017 09:44:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=ilija.tovilo@me.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ilija.tovilo@me.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain me.com designates 17.110.69.252 as permitted sender) X-PHP-List-Original-Sender: ilija.tovilo@me.com X-Host-Fingerprint: 17.110.69.252 mr11p00im-asmtp001.me.com Received: from [17.110.69.252] ([17.110.69.252:29336] helo=mr11p00im-asmtp001.me.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 62/4C-10715-E7905B95 for ; Sun, 10 Sep 2017 05:44:32 -0400 Received: from process-dkim-sign-daemon.mr11p00im-asmtp001.me.com by mr11p00im-asmtp001.me.com (Oracle Communications Messaging Server 8.0.1.2.20170607 64bit (built Jun 7 2017)) id <0OW2003005DDWA00@mr11p00im-asmtp001.me.com> for internals@lists.php.net; Sun, 10 Sep 2017 09:44:17 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=04042017; t=1505036657; bh=eqTQo3sekUsYD6Z/0POq0FSX/ZehdKcqpv1azl8HYXE=; h=Date:From:To:Message-id:Subject:MIME-version:Content-type; b=0iMQ4F4P8sfwTnXNDNUa0zTT4hYRcJGhprEHM55QVo9/098kqLvyibKm+4PhF6l70 hCpciZSz2dtSxm94d0BrWv8C8KHnzbnbE+MsrncK1PvqTsMpXPBU+51b9t9Tz4x8hI I2t2GAq45+/FxcD8vot8h1ax9VoVFqox9WuiG8PmN15MlmYCOMDxohZyYpCylcFwyt /02QfqtQ2zz9IL5o2VimflCzur971FyxP1vG+2gBdoWJNllfw0CFXOsqhsh0H1zS8r KvG3w6j4u2OWLbrt8c8+aUnTJ4j3H5IXjYOUSdysuXJ4I1nrsey1oAG734isPMmMVy PTDDsM6qIEnhQ== Received: from icloud.com ([127.0.0.1]) by mr11p00im-asmtp001.me.com (Oracle Communications Messaging Server 8.0.1.2.20170607 64bit (built Jun 7 2017)) with ESMTPSA id <0OW2008845PPZI20@mr11p00im-asmtp001.me.com>; Sun, 10 Sep 2017 09:44:16 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-09-10_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1011 suspectscore=74 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709100158 Date: Sun, 10 Sep 2017 11:42:16 +0200 To: internals@lists.php.net, Tony Marston Message-ID: <7cd2884a-6606-4c3f-8f95-776fd277878b@Spark> In-reply-to: <7B.DB.10715.48405B95@pb1.pair.com> References: <7B.DB.10715.48405B95@pb1.pair.com> X-Readdle-Message-ID: 7cd2884a-6606-4c3f-8f95-776fd277878b@Spark MIME-version: 1.0 Content-type: multipart/alternative; boundary=59b5096a_2ae8944a_17f67 Subject: Re: [PHP-DEV] Re: [RFC] Match expression From: ilija.tovilo@me.com --59b5096a_2ae8944a_17f67 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi Tony > =E2=80=A6 you sometimes forget to insert a break=C2=A0statement then th= at is your fault. Any bug in your source code is ultimately your fault. But as mentioned be= fore human error is inevitable. You can make it easier for your users to = make less mistakes though. Other languages (e.g. Rust or Swift) have impl= icit breaks in their switch statements. This has been done for a reason, = I wouldn=E2=80=99t call this a non-issue. > Millions of other programmers have no problem with the switch statement= It=E2=80=99s all they know. They don=E2=80=99t complain about null pointe= rs even though it=E2=80=99s inventor calls it his=C2=A0billion-dollar mis= take. The customer rarely knows what he truly needs. > they would not be pleased to have it changed just to deal with your=C2=A0= perceived problem with it I don=E2=80=99t suggest altering the behaviour of the switch statement bu= t rather to introduce a new match statement. Ilija On 10 Sep 2017, 11:23 +0200, Tony Marston , wr= ote: > wrote in message news:eb28362c-4f8f-45df-bbf0-582e8ad2b8af=40Spark... > > > > Hi everybody=21 > > > > Has this idea been discussed before=3F > > > > I find myself writing switch statements in PHP quite rarely. This has= a few > > reasons: > > > > 1. It doesn=E2=80=99t have a =22strict=5Ftypes=E2=80=9D 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 easie= r to > > read than the switch statement. > > What I=E2=80=99d really love is something like a match expression: > > > > If there are circumstances where a series of if / elseif statements tur= n out > to be shorter, safer and easier to read than a switch statement, then t= he > intelligent thing to do would be to use if / elseif statements instead = of > trying to make the switch statement more complicated. If your problem w= ith > 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 t= hem. > 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 > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > --59b5096a_2ae8944a_17f67--