What Silk is for
Use Silk for native tools and libraries where callers need to see the dependencies, possible failures, and contracts in the source.
Start with an order calculator. As it grows, share the pricing rule and handle invalid input.
Put a rule beside the code#
A withdrawal must leave a non-negative balance. This contract fragment makes that rule checkable:
#require balance >= 0;
#require amount >= 0 && amount <= balance;
#assure result == balance - amount;
#assure result >= 0;
fn withdraw (balance: int, amount: int) -> int {
return balance - amount;
}
The compiler proves the contract where it is used. Run the full example to validate CLI input, prove a guarded call, and see an unguarded call fail verification.
Choose a path#
Build a command-line tool, reuse a package, or expose a C ABI. Check targets and capabilities when choosing a target or feature.
Source repository · Edit this page · View Markdown