Contract programming syntax

Stewart Gordon smjg_1998 at yahoo.com
Thu Apr 9 14:14:32 PDT 2009


Tomasz Sowiński wrote:
<snip>
> 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?

Probably not, but I'm not sure I like it at all.  Firstly, it reminds me 
of the old crocky C syntax for declaring parameter types.  Secondly, if 
we're going to allow contracts on abstract/interface functions, would 
you need to write two semicolons in a row with this syntax?

(Maybe there's no need for a semicolon in lieu of the body in such 
cases.  It's just what the compiler used to allow, though it never 
actually did anything with the contracts.)

Stewart.



More information about the Digitalmars-d mailing list