Contract programming syntax

Tomasz Tomasz
Thu Apr 9 04:07:14 PDT 2009


Jarrett Billingsley Wrote:

> OK, then what about:
> 
> void foo()
> in { ... }
> out { ... }
> { ... }
> 
> the 'body' keyword is completely arbitrary.  There is no ambiguity here.
> 
> Also, I almost never use contracts because of their verbosity.  It's
> much shorter - and functionally equivalent - to just put asserts in
> the function body, some at the beginning and some in a scope(exit).

I like removing "body". But maybe we can make contracts a bit nicer by removing braces if the contract contains only one statement:

void foo()
in assert(something);
out assert(something_else);
{ ... }

would that be ambiguous to the compiler?

Tomek



More information about the Digitalmars-d mailing list