logoalt Hacker News

rramadass • today at 6:16 AM • 0 replies • view on HN

> If I understand contracts right, as in, that they're a basic form of dependent typing,

No, C++ contracts have nothing to do with the type system. It is purely predicate calculus using Hoare logic where subsets of state space are filtered from a larger program state space. The program is basically "steered" through the global state space using pre/post conditions.

Note however that theoretically (i.e. following from Curry-Howard correspondence) contracts can be thought of as dynamic counterparts to dependent types. But that is in a functional language with typing using constructive logic and not in an imperative language.