Contract programming syntax
Christopher Wright
dhasenan at gmail.com
Wed Apr 8 15:41:25 PDT 2009
Jarrett Billingsley wrote:
> 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 { ... }
> { ... }
I wouldn't mind that terribly.
> 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 use them with some frequency. I find their overhead to be minimal.
More information about the Digitalmars-d
mailing list