Re:A Few Good Ideas in Programming Languages
by WalterBright on Saturday September 12, 2026 @02:41PM
(#49675690)
In D, the covariance/contravariance of contract inheritance is an important aspect of the contracts.
Refinement types can be used as compile time checks for preconditions and postconditions, while this contract programming is inserting runtime checks.
Here's a good post on the type state pattern in Rust (we don't actually have refinement types in something like Rust but the type state pattern is somewhere closer to refinement types on this spectrum): https://cliffle.com/blog/rust-typestate/