-
-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Background:
Wave currently lacks support for enumerated types, which are commonly used to define a set of named values. Adding enum support will make it easier for developers to represent and handle fixed sets of related constants, such as states, types, or modes, in a type-safe and readable way.
Expected Behavior:
The Wave language should allow users to define enums using a simple and clear syntax. Each enum variant should be associated with an integer value starting from 0 by default, but explicit values should also be supported. Enum types should be strongly typed and usable in variables, conditionals, pattern matching, and function parameters/returns.
Example:
enum Color {
Red,
Green,
Blue = 10,
Yellow
}
fun print_color(c: Color) {
if (c == Color::Red) {
println("The color is red.");
}
}
User Scenarios:
-
A developer wants to define a finite set of game states (
Start,Playing,Paused,GameOver) and use them in game logic. -
An OS developer wants to define different file permission types or error codes using enums.
-
A library author wants to provide clear and readable configuration options via enums for API users.
Additional Information:
-
Enum support should integrate well with Wave’s type system and LLVM IR generation.
-
Pattern matching and switch-style branching based on enum variants may be considered for future extensions.
-
Enum-to-int and int-to-enum conversions should be explicitly handled or disallowed to preserve type safety.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status