# with

Bind a match payload

Last updated: 2026-09-09

Package: language | Status: experimental

Tags: cpu, keyword, language, logic, yeho

Use an enum when the valid states are finite and you want the compiler and reader to see every named possibility.

```yh
with
```


## Complete program

Bind the explanation carried by a failed result and display it.

Verification: type checked

```yh
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") }
}

```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.word__with"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

```

Extract the example archive beside the yeho and dolphin checkouts. This example requires those source dependencies and a current developer compiler.

```sh
./yeho/build/dolphin-metal/yehoc ./api-examples/word--with/complete --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


Plain enums are stable enough for ordinary use; richer payload matching remains experimental across targets.

The removed choice spelling is not accepted. Use enum.

Source: yeho/parser_declarations.cpp parseEnumDecl; parser_statements.cpp parseMatchStatement; conformance payload-enum-patterns

AI training permission: https://demonhunterlabs.com/ai-use
