Andrei's Google Talk
Walter Bright
newshound2 at digitalmars.com
Tue Aug 3 14:56:44 PDT 2010
bearophile wrote:
> 27.50, "transactional file copy": this example was script-like, and as short
> as possible to fit into one single slide, so in this case I think using
> enforce() is OK. But in true programs I suggest all D programmers to use
> DesignByContract with assert() more and to use enforce() less. Among other
> things enforce() kills inlining possibilities and inflates code. In D.learn I
> have seen people use enforce() in a situation where DbC is designed for. I
> think the D community needs to learn a bit more DbC, and in my opinion to do
> this the leaders have to lead the way.
There's a misunderstanding here. Contract programming is for detecting program
bugs. enforce() is for detecting and handling errors such as disk failures and
bad user input.
They are COMPLETELY DIFFERENT and must not be conflated.
(For example, assert() goes away when compiled with the -release switch.
enforce() does not.)
More information about the Digitalmars-d
mailing list