Why/where should I use contracts vs debug statements? Is it completely arbitrary? If so, I wonder if contracts syntax is even needed:

   int foo(int bar)
   in
   {
       assert(bar != 0);
   }
   body
   {
       return bar + 1;
   }

The thing I like more about debug statements, is that I can put them anywhere in my code, testing parameters and locals in the same way. If "for documentation" is the only argument for contracts, I find that a bit weak.

   int foo(int bar)
   {
       debug assert(bar != 0);

       return bar + 1;
   }

That is much cleaner syntax and just as easy to understand from a assertion-failure/documentation standpoint IMO.

Reply via email to