A question about DbC
Denis Koroskin
2korden at gmail.com
Sat Oct 9 03:47:52 PDT 2010
On Sat, 09 Oct 2010 14:44:41 +0400, Jonathan M Davis <jmdavisProg at gmx.com>
wrote:
> On Saturday 09 October 2010 03:25:48 Denis Koroskin wrote:
>> Well, I meant they are conceptually pure.
>
> Yes, they are conceptually pure, just not actually pure.
>
>> But do believe you shouldn't be able to use writeln in code like that.
>> Why
>> would you do it anyway? It's more or less like using assert just for a
>> console output:
>>
>> try {
>> assert(false, "message");
>> } catch {
>> }
>>
>> Put your logging stuff into the body, not into the contracts.
>
> It's for debugging, not logging. It's highly useful for stuff like
> figuring out
> which a contract is failing. That's the main reason why contracts are
> only
> conceptually pure rather than actually pure.
>
> - Jonathan M Davis
Why not just throw an exception and get a nice stack trace?
More information about the Digitalmars-d-learn
mailing list