Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100499 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4035 invoked from network); 10 Sep 2017 10:34:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Sep 2017 10:34:09 -0000 Authentication-Results: pb1.pair.com header.from=ilija.tovilo@me.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ilija.tovilo@me.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain me.com designates 17.110.69.253 as permitted sender) X-PHP-List-Original-Sender: ilija.tovilo@me.com X-Host-Fingerprint: 17.110.69.253 mr11p00im-asmtp002.me.com Received: from [17.110.69.253] ([17.110.69.253:48097] helo=mr11p00im-asmtp002.me.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D7/FC-10715-E1515B95 for ; Sun, 10 Sep 2017 06:34:08 -0400 Received: from process-dkim-sign-daemon.mr11p00im-asmtp002.me.com by mr11p00im-asmtp002.me.com (Oracle Communications Messaging Server 8.0.1.2.20170607 64bit (built Jun 7 2017)) id <0OW200D007UNFV00@mr11p00im-asmtp002.me.com> for internals@lists.php.net; Sun, 10 Sep 2017 10:33:48 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=04042017; t=1505039628; bh=fE+BL07MTF079zDOVw9JGLJmQejHjAkP9nWa/XrhcBY=; h=Date:From:To:Message-id:Subject:MIME-version:Content-type; b=Q+5OnwKoz+4L5p6clkbQiPHqx+eCpAjffDPvmzC+LbTcSAYSi/E078d6yB2XNx7YT 3hkYDM15seYyzDapIjcHOWNqvb9ZWeJrChKRc6nJWZmeXQDQU37Al83Ik1TB47cgYw MpGsqAiIV/G/S0jyRIbuqIzYa84tca5PD+DDKYgxwr8kLwyk3VZscvEjurAoJa/EIK atrJLTQFUvq8PPxXbHD5lkHGGslC6/3YhQyXpjglE8T4sPRnI9zgUkNFXvz2cVoFsV xzOzidrnTKm+iZStklNk1grQJkfkUfoQRqqo9RASuMp2ZHKJnHIedrvThP0TBznyX/ xZLL2iUSZpuXw== Received: from icloud.com ([127.0.0.1]) by mr11p00im-asmtp002.me.com (Oracle Communications Messaging Server 8.0.1.2.20170607 64bit (built Jun 7 2017)) with ESMTPSA id <0OW200HFB806GF20@mr11p00im-asmtp002.me.com>; Sun, 10 Sep 2017 10:33:45 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-09-10_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1015 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-1709100170 Date: Sun, 10 Sep 2017 12:32:48 +0200 To: internals@lists.php.net, Tony Marston Message-ID: <3b05768a-95b7-42de-8bb8-3d9ce0cce3a5@Spark> In-reply-to: <14.AC.10715.07215B95@pb1.pair.com> References: <7B.DB.10715.48405B95@pb1.pair.com> <7cd2884a-6606-4c3f-8f95-776fd277878b@Spark> <14.AC.10715.07215B95@pb1.pair.com> X-Readdle-Message-ID: 3b05768a-95b7-42de-8bb8-3d9ce0cce3a5@Spark MIME-version: 1.0 Content-type: multipart/alternative; boundary=59b51503_625558ec_17f67 Subject: Re: [PHP-DEV] Re: [RFC] Match expression From: ilija.tovilo@me.com --59b51503_625558ec_17f67 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline > it makes it impossible to group=C2=A0several conditions with a single b= reak In Swift you can group multiple conditions with a comma =60,=60 and in Ru= st with a pipe =60=7C=60. Here=E2=80=99s how that could look in PHP: =60=60=60php match (=24x) =7B =C2=A0 =C2=A0 1, 2: =E2=80=98One or two=E2=80=99; =7D =60=60=60 The only thing you cannot do is this: =60=60=60php switch (=24x) =7B =C2=A0 =C2=A0 case 1: =C2=A0 =C2=A0 =C2=A0 =C2=A0 echo =E2=80=9COne=5Cn=E2=80=9D; =C2=A0 =C2=A0 case 2: =C2=A0 =C2=A0 =C2=A0 =C2=A0 echo =E2=80=9CTwo=5Cn=E2=80=9D; =C2=A0 =C2=A0 =C2=A0 =C2=A0 break; =7D =60=60=60 Meaning you cannot =E2=80=9Cbleed through=E2=80=9D the first case into th= e second, executing both in case of =60=24x=60 being =601=60. This is acc= eptable IMO because this looks like a bug even if it=E2=80=99s intended. > =C2=A0then why can't you use if/elseif=C2=A0instead of making the langu= age more complicated=3F Because that=E2=80=99s usually the perfect use case for a switch statemen= t. On 10 Sep 2017, 12:22 +0200, Tony Marston , wr= ote: > wrote in message news:7cd2884a-6606-4c3f-8f95-776fd277878b=40Spark... > > > > Hi Tony > > > > > =E2=80=A6 you sometimes forget to insert a break statement then tha= t is your > > > fault. > > > > Any bug in your source code is ultimately your fault. But as mentione= d > > before human error is inevitable. You can make it easier for your use= rs to > > make less mistakes though. Other languages (e.g. Rust or Swift) have > > implicit breaks in their switch statements. This has been done for a > > reason, I wouldn=E2=80=99t call this a non-issue. > > The problem with implicit breaks is that it makes it impossible to grou= p > several conditions with a single break. My previous language use implic= it > breaks, and this problem really annoyed me. With PHP I have more contro= l, > and the fact that I have to insert explicit breaks I do not see as an > inconvenience. > > > > Millions of other programmers have no problem with the switch state= ment > > > > It=E2=80=99s all they know. They don=E2=80=99t complain about null po= inters even though it=E2=80=99s > > inventor calls it his billion-dollar mistake. The customer rarely kno= ws > > what he truly needs. > > They know what they want to achieve, and they have to know which langua= ge > features are available to help them meet their objectives. The fact tha= t > some language features have turned out to be a big mistake is purely th= e > fault of the people who introduced those features. Some programmers com= plain > about some languages features even though they are useful features whic= h > work as advertised as are not deemed to be a mistake - take yourself fo= r > example who is now complaining about issues with the switch statement. > > If what you want to achieve can be done better with a series of if/else= if > statements than the switch statement, then why can't you use if/elseif > instead of making the language more complicated=3F > > -- > Tony Marston > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > --59b51503_625558ec_17f67--