Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:76474 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15875 invoked from network); 13 Aug 2014 10:56:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Aug 2014 10:56:59 -0000 Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.178 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.216.178 mail-qc0-f178.google.com Received: from [209.85.216.178] ([209.85.216.178:52147] helo=mail-qc0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 91/D0-11625-A744BE35 for ; Wed, 13 Aug 2014 06:56:58 -0400 Received: by mail-qc0-f178.google.com with SMTP id x3so3892265qcv.37 for ; Wed, 13 Aug 2014 03:57:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=9fk9Kz8e2FjLMWI7yGOhHa/W9C2tXyQpB0HMwCjJf4I=; b=ArKwhzu8mZJN5AMuZ0UY5/FSOyUnQiEPFsspkwbRl7OPippNeLcQf+m5uCbCHe/QVd QAv1I1tnW0/LslEPMHRgnfo83KtUIy5uheIHjKd2U77pq+SbuM13ttrpQ8m5Sz2dV5Oc 2VbKHi91Z1PKSdrTdSjyeftdc2YYs+DpVAv1X1jMTvgoNU5A8ceMZNEpNInp0FFj9Zcq DeIAJYXWQz5dsYxNZ+9uUPKtZRsTo9vp4DBUo0eSK9ZYtSFxf7WPtgpyGNZZCg0YZuX/ CGz41F62kAyVmh2H2B2rkUcJFRRH01+aMs8Sd9FsFBDJ7Z0hMCrooUlZ7CGE5hK8tYC+ fOJQ== MIME-Version: 1.0 X-Received: by 10.229.131.5 with SMTP id v5mr1389166qcs.21.1407927460256; Wed, 13 Aug 2014 03:57:40 -0700 (PDT) Received: by 10.140.102.111 with HTTP; Wed, 13 Aug 2014 03:57:40 -0700 (PDT) In-Reply-To: <942D2AF6-BDC2-4214-BD58-4B5945C28CE3@ajf.me> References: <942D2AF6-BDC2-4214-BD58-4B5945C28CE3@ajf.me> Date: Wed, 13 Aug 2014 12:57:40 +0200 Message-ID: To: Andrea Faulds Cc: James , Sara Golemon , PHP internals Content-Type: multipart/alternative; boundary=001a1132e2b623616a050080a89c Subject: Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement From: tyra3l@gmail.com (Ferenc Kovacs) --001a1132e2b623616a050080a89c Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, Aug 13, 2014 at 11:42 AM, Andrea Faulds wrote: > Hi! > > On 13 Aug 2014, at 08:47, Ferenc Kovacs wrote: > > > and I also think that this isn't an important enough issue to warrant a > BC > > break (albeit this is the better kind of BC: probably doesn't effect to= o > > many people, and they will be clearly notified about the error at compi= le > > time) so I voted no based on this two thing. > > This isn=E2=80=99t really a BC break. Multiple default blocks didn=E2=80= =99t actually work > anyway, we just silently ignored extra ones. > not sure what do you mean here, multiple default cases can be reached the same way as any other duplicated case branch(as shown in my snippet in the mail you replied to). even if those were always "silently ignored" as you falsely claim, it would still be a BC break, as code working before this change would stop working with a fatal error. > > On 13 Aug 2014, at 09:13, James wrote: > > > I entirely believe this behavior is weird and should be removed. Howeve= r, > > breaking backwards > > compatibility in a minor release because the incomplete spec says so is > > kind of odd. A BC break > > is a BC break, which doesn't belong in a minor revision. > > It isn=E2=80=99t a BC break that will affect anyone. It fixes a parser bu= g. > it is a BC break, but I tend to agree that there isn't much code intentionally using this behavior (but I'm also think that nobody really looked for examples and just guessing about the usage of this feature), but we had explicit phpt test for this behavior so I would call it a bad design decision or lazy coding than an actual bug or hindsight. > > > This has been known to at least one person for many years if 034.phpt i= s > to > > be believed. > > Just because it=E2=80=99s tested doesn=E2=80=99t mean anyone relies on it= . We have plenty > of tests which ensure PHP contains bugs and will error if they don=E2=80= =99t. > sure, and those which we consider bugs are usually tests which expect the correct behavior and marked as XFAIL so we won't forget that they should be fixed. those which are testing and expecting the "bad" behavior is for us to not change those unintentionally, alas introduce unintentional BC breaks. > > > I could see > > where people would use it - there are reasons to, even if they are poor > in > > choice to do so. > > How, exactly, could there ever be a use for having multiple default: > sections and ignoring all but one? I think you forget the fall-through cases (eg. a case/default without a break/continue), in those cases all of the matching cases will be executed (even the duplicated ones as they are all matching) > This =E2=80=9Cfeature=E2=80=9D is completely and utterly useless, and I= =E2=80=99ll eat my hat if > anyone intentionally relied on it. > not sure about the multiple defaults, but I'm fairly sure that there are code out there which uses switch blocks as state-machines, and changes the switch variable in the case blocks, and have duplicated case blocks for executing code after the switch variable reached it's final form. and I consider the default block as a glorified wildcard case pattern, so I don't think that it is a good idea to prevent having multiple default blocks while allowing the normal case blocks to check for the same value multiple times. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --001a1132e2b623616a050080a89c--