Forums

DbC Control

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

DbC Control

Postby Steve » Sun Apr 27, 2008 7:07 am

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

--
Steve
 
Posts: 9

Re: DbC Control

Postby Charles » Sun Apr 27, 2008 11:42 am

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.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: DbC Control

Postby Steve » Sun Apr 27, 2008 2:04 pm

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

--
Steve
 
Posts: 9


Return to Discussion

Who is online

Users browsing this forum: No registered users and 50 guests