Concurrent programs talk through channels: one thread sends, another receives, and together they carry out a protocol. Get the order wrong â both wait for the other to go first â and you have a deadlock: the program freezes, and no error message explains why.
Ordinarily, protocols are informal. You write documentation, run tests, pray. Session types take a different approach: they make the protocol part of the channel's type, checked at compile time. Every channel carries a session type that prescribes the exact sequence of sends and receives expected from each end. The type checker verifies that sender and receiver are dual â one's send matches the other's receive, one's choice is the other's branch â and if they are not, the program simply does not compile.
The result is a remarkable guarantee: well-typed programs cannot deadlock (Honda, Vasconcelos and Kubo, 1998). This is not a runtime check, not a sanitizer, not a probabilistic guarantee. It is a mathematical proof embedded in every successful type check.
Comments
Loading comments...