Digital Mars C++ Compiler is the only C++ compiler which implements DbC. It isn't an open source project, but we can get it free. A programmer can write the contract naturally with this compiler.
It was developed by Walter Bright who is the D programming language developer. D is based on Digital Mars C++ Compiler.
How to write the contract with this compiler? We must write under-score as prefix for the contract:
long square_root(long x)
__in
{
assert(x >= 0);
}
__out (result)
{
assert((result * result) == x);
}
__body
{
return sqrt(x);
}
That DbC is like to D's style.
No comments:
Post a Comment