Re: [RFC] Disallow multiple default blocks in a single switch statement

From: Date: Wed, 13 Aug 2014 12:42:40 +0000
Subject: Re: [RFC] Disallow multiple default blocks in a single switch statement
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-76478@lists.php.net to get a copy of this message
On Wed, Aug 13, 2014 at 2:27 PM, Rowan Collins <rowan.collins@gmail.com> wrote: > Ferenc Kovacs wrote (on 13/08/2014): > >> 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. >> > > I'm not sure I agree that it's arbitrary. Having a switch with two > "default" clauses is like having an if with two "else" clauses; specifying > two case labels which can be true at the same time is like having two > "elseif" clauses chained together that can both be true at the same time. > One is clearly an error; the other is just poorly written logic, and you > can't make the parser outlaw every instance of poor logic. Default is more of a catch all directive than an else (which will only match if nothing else), so I don't think that having two default is more "wrong" than having two "case 2:". -- Ferenc Kovács @Tyr43l - http://tyrael.hu

« previous php.internals (#76478) next »