DIP 1009--Improve Contract Usability--Preliminary Review Round 1

Mark via Digitalmars-d digitalmars-d at puremagic.com
Fri Jun 30 07:24:16 PDT 2017


On Thursday, 29 June 2017 at 01:37:17 UTC, H. S. Teoh wrote:
> (1) DbC contracts pertain to *runtime* argument values, so while
> checking for simple cases at compile-time is nice, it isn't 
> really in
> the charter of (D's implementation of) DbC.
>
>
> T

That's a good point.

I guess UDAs combined with static assert is the right way to 
implement compile-time checkable contracts. This seems to be the 
approach taken by Andrei in his Big O notation library [1].

Anyway, contracts are still useful for documentation purposes, as 
was pointed out. Personally I like them because they encourage me 
to think carefully about the preconditions and postconditions of 
the functions I write.

[1] 
http://forum.dlang.org/post/mailman.898.1482091540.9448.digitalmars-d@puremagic.com


More information about the Digitalmars-d mailing list