State matching and decomposition
This page treats Vitte logic as an executable mechanism: each rule is linked to a concrete consequence in the program flow. Vitte matching replaces implicit state conventions with explicit and verified variants.
pick Job {
case Ready
case Running
case Failed(code: int)
}
proc status(job: Job) -> int {
match job {
case Ready { give 0 }
case Running { give 1 }
case Failed(code) { give code }
otherwise { give -1 }
}
}
Why this step is solid. pick formalizes the state space, match forces reading by variant and payload. The otherwise branch plays a robustness guard role.
What happens at runtime. status(Ready)=0, status(Running)=1, status(Failed(503))=503.
proc is_terminal(job: Job) -> bool {
match job {
case Failed(_) { give true }
otherwise { give false }
}
}
Why this step is solid. Terminality predicate derived from a variant. The intent is centralized into a short, reusable function.
What happens at runtime. is_terminal(Failed(1))=true, is_terminal(Ready)=false.
proc status2(job: Job) -> int {
select job
when Ready { return 0 }
when Running { return 1 }
otherwise { return -1 }
}
Why this step is solid. Style variation with select/when. The flow is readable in successive branches. Semantics remains a state decomposition.
What happens at runtime. status2(Ready)=0, status2(Running)=1, status2(Failed(9))=-1.
This page connects to the keywords pick, case, match, select, when, is in book/chapters/keywords/pick.html, book/chapters/keywords/case.html, book/chapters/keywords/match.html, book/chapters/keywords/select.html, book/chapters/keywords/when.html, book/chapters/keywords/is.html.