Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:76475 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17459 invoked from network); 13 Aug 2014 11:01:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Aug 2014 11:01:54 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.177 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.216.177 mail-qc0-f177.google.com Received: from [209.85.216.177] ([209.85.216.177:42658] helo=mail-qc0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 47/21-11625-0A54BE35 for ; Wed, 13 Aug 2014 07:01:52 -0400 Received: by mail-qc0-f177.google.com with SMTP id x13so3963515qcv.36 for ; Wed, 13 Aug 2014 04:02:34 -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=3M8bdpchpxvNeHdB8Eme5oFYidNOY/Wy+8+PTYv8ZQI=; b=D7neuz5umr00b8HI0w/qsr2e9V6udRS5HPm4npSbS8g7kO9pr485zw4qVCUKIJkzUd 7LmB212eMw9gpNXqjWxhsRRaKNKBg2ZE3XZWr8gS21x5B0j9OqxSlv0LdzpT78dkd6x/ DPOZQ0zh281Q8ELlT0yg9mZkW0yhFCQ8SfWTIfcvgyLlMSxGGB3AUzYi+63+9xJw1TT+ f8C7E+Dq4B6WkuwJroDyyWIGR6asj0DxSSszsVadTZLcxDMxsN1+LWpsTb8x9rbJjJxK J7v/VHvHRAgXHhpzERo2zsbILY4b2TxlMuB6esiHNeNrtw3k74UsVkJXku+BsmvGXehU oImw== MIME-Version: 1.0 X-Received: by 10.229.212.194 with SMTP id gt2mr5720128qcb.6.1407927754745; Wed, 13 Aug 2014 04:02:34 -0700 (PDT) Received: by 10.140.102.111 with HTTP; Wed, 13 Aug 2014 04:02:34 -0700 (PDT) In-Reply-To: <53EB3C6A.5010106@gmail.com> References: <53EB3C6A.5010106@gmail.com> Date: Wed, 13 Aug 2014 13:02:34 +0200 Message-ID: To: Rowan Collins Cc: PHP Internals Content-Type: multipart/alternative; boundary=001a11339280b107f9050080b922 Subject: Re: [PHP-DEV] [RFC] Disallow multiple default blocks in a single switch statement From: tyra3l@gmail.com (Ferenc Kovacs) --001a11339280b107f9050080b922 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, Aug 13, 2014 at 12:22 PM, Rowan Collins wrote: > 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 =3D 30; > // ... arbitrary amount of code > switch ( $foo ) { > case $bar: > case 30: > } > > agree, and I thought about mentioning that, but I left that out, because I'm not proposing to remove that ability (and I see more use-cases for that as mentioned in my previous email) but stating that this patch would make an arbitrary distinction between the normal and the default cases. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --001a11339280b107f9050080b922--