language · language ·
Enums, payloads, and match
enum names a closed set of cases. Payload cases can carry one typed value, and match selects a branch with an optional binding.
Use an enum when the valid states are finite and you want the compiler and reader to see every named possibility.
enum Name { Case, Payload(Type value) }
match value { Case { ... } Payload with name { ... } else { ... } }Status: experimental
Complete program
Bind the explanation carried by a failed result and display it.
cpu · language · type checked
enum Result
{
Ready,
Failed(text reason)
}
Result result = Result.Failed("The player name is missing")
match result
{
Result.Ready { Console.Log("Ready") }
Result.Failed with reason { Console.Log(reason) }
else { Console.Log("Unknown result") }
}
project.mech
manifestVersion = "2"
package = "api.example.language__enums_match"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"
[app]
kind = "headless"
Notes and source
Plain enums are stable enough for ordinary use; richer payload matching remains experimental across targets.
The removed choice spelling is not accepted. Use enum.
yeho/parser_declarations.cpp parseEnumDecl; parser_statements.cpp parseMatchStatement; conformance payload-enum-patterns