Background:
Wave currently supports if, while, and function calls, but lacks a native pattern matching construct.
Adding a match expression would allow more expressive and readable control flow, especially for handling enums, constant values, and future Option-like types.
Expected Behavior:
A match expression should support matching against values with multiple arms, including a default case.
For example:
fun main() {
var x: i32 = 2;
match x {
1 => println("one"),
2 => println("two"),
_ => println("something else"),
}
}
-
Each arm should end with an expression or block.
-
A wildcard (_) must be supported as a fallback/default case.
-
Future support should allow nested match, enum matching, and more.
User Scenarios:
- A developer wants to replace multiple
if-else chains with cleaner, declarative syntax.
- Future enum-based APIs (e.g.,
Option, Result) require pattern-based branching.
- Improves readability in cases like command parsing, state machines, or integer mapping.
Additional Information:
-
Language version: - (not yet assigned)
-
Target branch: develop
-
Parser and compiler will need updates to support match as an expression
-
Could later expand to support destructuring and pattern guards
Background:
Wave currently supports
if,while, and function calls, but lacks a native pattern matching construct.Adding a
matchexpression would allow more expressive and readable control flow, especially for handling enums, constant values, and futureOption-like types.Expected Behavior:
A
matchexpression should support matching against values with multiple arms, including a default case.For example:
Each arm should end with an expression or block.
A wildcard (
_) must be supported as a fallback/default case.Future support should allow nested
match, enum matching, and more.User Scenarios:
if-elsechains with cleaner, declarative syntax.Option,Result) require pattern-based branching.Additional Information:
Language version: - (not yet assigned)
Target branch:
developParser and compiler will need updates to support match as an expression
Could later expand to support destructuring and pattern guards