[plt-scheme] contracts.ss: Can you disable them at runtime?

From: Anton van Straaten (anton at appsolutions.com)
Date: Thu May 17 20:41:53 EDT 2007

Joe Marshall wrote:
> These tests were *amazingly* useful to us, but our customers loved
> them as well.  They would run these self-tests before submitting bug
> reports and send the output along with the bug report (anyone who
> fields customer support complaints will tell you how wonderful *that*
> is!)  We had logging diagnostics that were intended to be `turned off'
> at the customer site.  We never turned those off, either.
> 
> If you have tests, assertions, and contracts that you `turn off' when
> shipping, then the code the customer gets is *not* the same as the
> code you use in-house.  It may be your intention that it be, but you
> probably intended to ship bug-free software, too.  In a complex
> system, you should ship *exactly* the same bits to your customer as
> you use in-house.

I agree that this is a good model to aspire to.  But there are also 
cases where, during development, you want to ensure that some condition 
holds that isn't practical to test during every run of the live system.

If a mechanism that could be used to express such a condition doesn't 
support being turned off, you can either not check for it, or figure out 
some other way to turn it off - conditional code, macros, conditional 
builds, etc.  Which of course is done all the time in practice.

In any case, this shouldn't be a binary choice.  For example, typical 
logging tools offer levels of logging, and it's common to run live 
systems at some level below the full "debug" level.  Full debug logging 
can easily become prohibitively expensive.

Having the ability to support logging levels which can be turned off 
encourages use of the logging tool; without that, certain kinds of 
logging would have to be avoided entirely, or done some other way.

One bottom line is that unintended consequences are a factor here.

Anton



Posted on the users mailing list.