Page 1 of 1

DbC Control

PostPosted: Sun Apr 27, 2008 7:07 am
by Steve
Is there a facility in Cobra that would allow me, when moving from development to production, to generate code that contains preconditions but not postconditions or invariants?

Let me know and best regards as always,


Steve

--

Re: DbC Control

PostPosted: Sun Apr 27, 2008 11:42 am
by Charles
At compile-time, you can turn them off completely with -contracts:none

At run-time, you can turn off checks like so:
CobraCore.willCheckInvariant = false
CobraCore.willCheckEnsure = false

# there are 5 CobraCore shared properties for this:
pro willCheckInvariant from var
pro willCheckRequire from var
pro willCheckEnsure from var
pro willCheckAssert from var
pro willCheckNil from var

.willCheckNil affects (1) checking that parameters with non-nil reference types are not nil and (2) casts such as "x to !"

Using these won't completely eliminate overhead, but will greatly reduce it.

I agree these should be available as compile-time options that affect the code generation. I encourage you to submit your first ticket.

Re: DbC Control

PostPosted: Sun Apr 27, 2008 2:04 pm
by Steve
Chuck wrote:I agree these should be available as compile-time options that affect the code generation. I encourage you to submit your first ticket.


Done.

Thanks for your help,


Steve

--