Replies: 1 comment 7 replies
-
You can write that as either: switch n {
case 0: //do no thing
case 1, 2, 3: do_thing()
} Or: switch n {
case 0: //do no thing
case 1: fallthrough
case 2: fallthrough
case 3: do_thing()
} |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
New to the language. I started reading the documentation and then looking at the source code for the compiler. It seems like it'd be relatively straightforward to have a c-like switch if there isn't one already. Seeing how
#partial
looks like it ignores unhandled cases, I'm thinking a#fallthrough
tag orswitch fallthrough
. In the event someone wants fallthrough behavior by default. A tag appears to be far easier to do.To be fair most of the code I've put in switch blocks doesn't use fallthroughs, but every once in a while it just makes sense. While I'm incredibly used to ()'s being everywhere I do like the different variations of for and switch statements. I'm not exactly invested in the language, but since it seems like it's designed with as few keystrokes in mind, I think someone might like this.
Relevant area in the parser for anyone who'd want to add it as a tag:
Odin/src/parser.cpp
Line 4689 in 7b539e3
I might build the compiler myself and see if I can't work out how to do this for fun.
Beta Was this translation helpful? Give feedback.
All reactions