Contract programming syntax

Jarrett Billingsley jarrett.billingsley at gmail.com
Wed Apr 8 14:10:42 PDT 2009


On Wed, Apr 8, 2009 at 4:51 PM, Christopher Wright <dhasenan at gmail.com> wrote:
>
> No. This proposed syntax change is quite misleading. Contracts cannot access
> the function's local variables, but it looks like they can. Contracts are
> executed at particular times, but that syntax makes them look like they
> execute wherever they are written.
>
> I believe you can put "body" before each function body, even with no
> contracts, if it makes you happier.

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).



More information about the Digitalmars-d mailing list