Multi-values in switch-case --------------------------- Simple but maybe naive solution: case 1 case 2 case 3 ... # what if this is commented out? case 4 ... case 5 ... This is tricky, because it could lead to inadvertent fallthrough if the case "body" is commented out. Some languages have an explicit `break` or `end` to avoid that. C style: case 1: case 2: case 3: ... break; case 4: ... break; case 5: ... break; Pascal-style: case 1..3 begin ... end; case 4 begin ... break; case 5 begin ... end; Gambas/Basic-style: case to 0 ...report error... case to 3 ... case 4 ... case 5 ... Using special multi-case syntax: case 1 2 3 then ... case 4 ... case 5 ... Putting multiple items in one line: (can be hard to read with many items, and how to wrap lines?) case 1 2 3 ... case 4 ... case 5 Multi-case with `or` keyword: case 1 or 2 or 3 ... case 4 ... case 5 ... Or with `also` for better alignment (best solution?): (this can be combined with multiple items per line) case 1 also 2 also 3 ... case 4 ... case 5 ... Advanced switch case expressions -------------------------------- The Gambas programming language has patterns. From it's documentation: case like "*.{png,jpg,jpeg,bmp}" Another way is to allow function calls as the case expr: case pattern "*.bmp" ... case regex "*\.(jpe?g|webp)" ... To allow for show identifiers like `pattern`, `regex` or `like`, it could search in the namespace of a special generic class, such that different types can have different namespaces. E.g. `CaseMatch of String` for strings and `CaseMatch of int` for integers (and `CaseMatch of long` for long, etc.). Perhaps there could also be some optimization to match against multiple values efficiently. Maybe there could be a `MulitCaseMatch of Xxx` which could be instantiated with the value once, and then efficiently compared against all values in one go. There's also the matter of compilation of patterns. Not sure how to implement that, because SLUL isn't going to have static initialization. Maybe it could be done with CTFE (compile-time function evaluation)? But then the pre-compilation optimization cannot be improved with library upgrades.