[swift-evolution] [Pitch] Introduce continue to switch statements
xiaodi.wu at gmail.com
Mon Jul 11 00:54:34 CDT 2016
I disagree. First, in both cases there's an A and a B. The two scenarios we
are comparing are "if condition continue, else break" and "if condition
continue, else fallthrough". Both break and fallthrough are equally control
transfer experiments. Both of these scenarios add complexity for reasoning
(compare case B and case C in my example above).
Obviously, in code, whichever of statement A or B is first reached will
preclude execution of the other. But the whole point of control flow
statements is to provide an expressive way to branch when necessary. If we
agree that the complexity introduced by `continue` is worthwhile and
useful, then "if condition continue, else fallthrough" is just as
legitimate a use case as "if condition continue, else break."
As such, I'd conclude that I'm neutral on the proposal (I could do without
it, but it would be intriguing and Swifty to empower the switch statement
further). However, if adopted I'd strongly urge having all uses of continue
permitted. Including something like `continue case 0..<2 where y < z` if a
subsequent case is written as such, since after all cases are syntaxed like
On Mon, Jul 11, 2016 at 00:44 Erica Sadun <erica at ericasadun.com> wrote:
> > On Jul 10, 2016, at 11:42 PM, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
> > Right. Both seem equally reasonable alternatives if a condition isn't
> fulfilled where I'd like to continue pattern matching. Why do you say one
> of these would be fair to disallow?
> I'm saying pick behavior A or behavior B but don't do A & B because that
> makes computing the possibilities unnecessarily complex and I cannot think
> of a single real-world use-case where one would want to do both at the same
> -- E
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution