Re: New switch/case idea

new topic     » goto parent     » topic index » view thread      » older message » newer message

Continue is a natural thing for a language that has switches with an optional 'without fallthrough' syntax. The reason why continue was shot down was that it might have been confusing with loop control. By putting continue in the case statement itself there is no longer ambiguity.

Sometimes, you have a switch statement and most of the time you have no fallthough but occasionally you need fallthrough. So because a switch needs fallthrough 20% of the time you need to put 'break' in 80% of the switches. With Fernando's proposal the programmer can elect to put 'continue' in 20% of the statements. Look at execute.e's switch statement. Look at all of those breaks, with present syntax we cannot change it to no fallthrough because we actually need fallthrough once and a while but not often.

Presently, you have switch with fallthru for when you need to fallthrough at least once. And switch without fallthru if you never need fallthrough. What a pain if the user chooses the without fallthrough path and then finds that he needs fallthrough later.

With Fernando's proposal, you can use either with fallthrough or without no matter how many times you need to or will need fall through in the cases. The programmer can choose what is the most convienent for the particular situation.

Suppose we keep the ability to choose which default to use in a switch with 'with fallthru' or 'without fallthru' and we allow users to override with the old 'break statement' and the 'continue specifier in the case header. It's only a modification to what was agreed apon, I don't see why we cannot simply vote on that.

I don't think this new idea is mutually exclusive to what was agreed apon earlier regarding the switch statement. We have two kinds of switch statements, one with fallthru and one without. With fallthru we can override a case's behavior with a break statement so that some cases fall through. Fernando's proposal is to me like a mirror image of the break statement for the non-fallthrough world. I vote we integrate it into the existing syntax.

Shawn Pringle

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu