Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:76470 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8586 invoked from network); 13 Aug 2014 10:21:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Aug 2014 10:21:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.180 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.180 mail-we0-f180.google.com Received: from [74.125.82.180] ([74.125.82.180:60949] helo=mail-we0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 44/71-33745-24C3BE35 for ; Wed, 13 Aug 2014 06:21:55 -0400 Received: by mail-we0-f180.google.com with SMTP id w61so11045507wes.11 for ; Wed, 13 Aug 2014 03:22:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=RiXA8cVc2tSwmiropTXcgWngVGs+t2Dmr48fyxlVbLQ=; b=h2dzmKrSB+njlilaITkLpWxCV9Wzhx783qAQ2fT3n3FHIR873qbEFMYcCym/Z1fD/k 5aBtZ7EJ2K/XriuDqToyz87SXI8IB4r5KuNKnNxAcbOTe/B76Pk7dy6osuuW1H9kBZqg LYW4nle1D1z7alUMn87kexfeK7Ktvlr6nTDG5Ki7YTONwZX5jlRTKXRJzoM90xpXZ1bM HS2NwSPAzT2l8ahOPoLxpxGONfhUUSEj+kbxyXqb+9VA/WLYadvyP2ymlMNAnS/itk13 8tgq5I3pkOPyeUzzcrmTkMSr4PAyn4PaewrJdbJLbTmH2eBVwnqOk0ZbK9V7G7BBfMNV O+xQ== X-Received: by 10.180.89.161 with SMTP id bp1mr37463178wib.49.1407925355702; Wed, 13 Aug 2014 03:22:35 -0700 (PDT) Received: from [192.168.0.177] ([62.189.198.114]) by mx.google.com with ESMTPSA id gl4sm66429351wib.19.2014.08.13.03.22.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 13 Aug 2014 03:22:34 -0700 (PDT) Message-ID: <53EB3C6A.5010106@gmail.com> Date: Wed, 13 Aug 2014 11:22:34 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement From: rowan.collins@gmail.com (Rowan Collins) Ferenc Kovacs wrote (on 13/08/2014): > sorry to jump in this late, but I'm not sure that it is a good idea to only > reject the multiple default blocks but keep the ability to have the same > case multiple times: > http://3v4l.org/eZdPU Multiple cases with the same value are a lot harder to prevent (if not impossible), because there is no requirement for the cases to be static, or of the same type. The spec actually calls this out with a couple of examples: https://github.com/php/php-langspec/blob/master/spec/11-statements.md#the-switch-statement It would be a bit awkward if this was a syntax error: switch ( $foo ) { case 30: case 30: } But this was fine: switch ( $foo ) { case 30.0: case 30: case 10 * 3: } And this, which is completely undetectable at parse time: $bar = 30; // ... arbitrary amount of code switch ( $foo ) { case $bar: case 30: } -- Rowan Collins [IMSoP]