'continue' and 'break' in case blocks #9
Comments
continue
and break
in case blocks
I also like using |
It is also ironically echoing C's use of |
There is one downside to giving
Thinking about my own experience, I wanted to break out of an Together, I think this may be a strong argument in favor of making |
I agree. |
One aspect of match x:
case foo(2): ...
case foo(3): ...
case bar(a): ... is actually compiled down to hierarchical code like this: if isinstance(x, foo):
if foo.arg == 2: ...
elif foo.arg == 3: ...
elif isinstance(x, bar):
.... Introducing Anyway, I also fully agree with that match statements are more likely to contain a So, long story short, I would not include |
@brandtbucher -- any final words about this? Otherwise I propose to label this as "rejected". |
Nope, great points have been made. I agree that the drawbacks outweigh the benefits. |
Let's keep rejected issues open though. I like to have the full discussion visible. |
Agreed - a rejected issue is not 'closed' because there is still work to be done - writing up the reason why it was rejected. (If an issue had no impact at all on the PEP, then I suppose theoretically we could close it.) |
@brandtbucher proposed to support
continue
in case blocks, with the semantics of skipping forward to the next case. This could be used instead of guards (#3). E.g.If we were to support this we could also support
break
, which would exit thematch
statement.Note that
continue
could also be used to emulate C's "fall-through" behavior (which should definitely not be the default):The text was updated successfully, but these errors were encountered: