Denis Koroskin wrote:
On Mon, 03 Aug 2009 16:22:40 +0400, Michiel Helvensteijn
<[email protected]> wrote:
Denis Koroskin wrote:
Then I assume you still want to restrict the precondition to being the
first element in the body? Because putting it in there suggests that it
may appear anywhere a statement can.
Why not?
Because a function precondition indicates the set of admissible states
before execution of a function. Emphasis on *before* and *function*.
Allowing them anywhere inside a function body will only improve the
feature.
BTW, it is already allowed, just use 'debug' instead of 'in':
Suggested way:
int foo(int a) {
in {
assert(a>2);
}
return a-1;
}
My way:
int foo(int a) {
debug {
assert(a>2);
}
return a-1;
}
TBH, I'd just drop the whole DBC feature from a language, it creates
more problems than solves.
I think the interesting uses are when you can e.g. specify constraints
on an interface, inherit them, add to them in derived classes etc. What
DbC support is in the language so far adds very little compared to debug
and scope(success).
Andrei