-
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
discussionIssues that require a technical or community discussion.Issues that require a technical or community discussion.enhancementA request for a new feature or improvement.A request for a new feature or improvement.feature requestA request for a new feature or functionality.A request for a new feature or functionality.
Description
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-elsechains 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
Metadata
Metadata
Assignees
Labels
discussionIssues that require a technical or community discussion.Issues that require a technical or community discussion.enhancementA request for a new feature or improvement.A request for a new feature or improvement.feature requestA request for a new feature or functionality.A request for a new feature or functionality.
Type
Projects
Status
Backlog