Contracts or Exceptions?

Mike Linford mike.linford.reg at gmail.com
Tue Mar 29 11:40:02 PDT 2011


Hello,

So I'm writing a function for a library. It takes a struct as an 
argument. The struct's fields can't just be any old values, though. The 
function won't work if some of the fields are weird. It could return an 
erroneous value, or even crash. 

The thing is, though, that I can't tell whether the best approach is to 
use an in-contract or throw an exception if it doesn't pass my test. What 
would you guys recommend?



-- 
--Mike Linford


More information about the Digitalmars-d-learn mailing list