Support for a switch
operation
#819
Labels
enhancement
New feature or request
subject: code generation
This issue is about code generation
subject: model validation
This issue is about validation of Rosetta models, such as the type system
subject: syntax
This issue is about the syntax of Rosetta
It is often useful to model a case analysis based on an enum, string or number, e.g.,
It would be useful to have a shorthand operation for this, e.g.,
In case of switching over an enum value, Rune would validate that all enum values have been exhausted, otherwise indicating to the modeller that they forgot a case. As a catch-all, the
default
keyword can optionally be used at the end. This validation would improve consistency while refactoring, as new enum values will automatically indicate to the modeller which expressions should be updated.In case of switching over basic types such as strings or numbers, no validation would be present, and a
default empty
is assumed implicitly.Implementation consequences
The Rune language adds a new expression to its syntax. Code generators supporting expressions (Java, Python) will need to implement its semantics.
The text was updated successfully, but these errors were encountered: