Brandon J. Van Every wrote:

> Thomas Christian Chust wrote:
>
>> [...]
>> all the contract based programming systems I know don't come up with a
>> specific language for describing the contracts. I usually see contract
>> based programming systems as syntactic sugar allowing you to specify
>> arbitrary code which will be run upon entry to and exit from a function.
>>   
> 
> How is that better than just writing tests then?

Hello,

it's not better, but there is an important difference in the mode of
operation.

Unit tests are usually bundled into a test driver program -- either by
hand or by some automatism -- that is run once every time the code
changes to find any possible bugs in your library functions. The
important point is that each unit test you wrote is *run exactly once*
by the test driver program.

Contracts are compiled into the library itself when they are enabled and
they get *run every time the functions they belong to are called*.

So while tests are good for feeding your functions some pathological
inputs to see whether they still work, contracts are great to determine
whether the functions *and their callers* behave correctly during normal
operation of the final program -- and maybe to discover more
pathological cases to check for in the test suite ;-)

Actually we already have the choice to disable some kind of contract
checking in CHICKEN by using the unsafe runtime libraries.

cu,
Thomas



_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to