Why is there no static contract verification?

Jesse Phillips Jesse.K.Phillips+D at gmail.com
Sun Feb 2 11:31:59 PST 2014


On Sunday, 2 February 2014 at 18:37:34 UTC, Mario Schmidt wrote:
> I'm new to D. Currently I'm programming in C# and I am looking 
> for a secondary, or even new main language that D might become.
>
> One of the features that I found most promising in D is DbC. 
> However, I was very disappointed when I realized that the 
> current implementation is not much more than an assert that is 
> evaluated during runtime.
>
> What i mean is.. look at this code:
>
> void goCrazy(Person p)
> in { assert(p); }
> body {
> // whatever
> }
>
> void main()
> {
> Person goku = null;
> goCrazy(goku);
> }

The compiler may be able to identify simple cases, but reality is 
going to be a hit and miss. I think the goal here would be for 
goCrazy to take a NotNull!Person (but that implementation isn't 
finish).

On another note, in/out contracts don't appear to get much use in 
the community. I use them once in awhile, but don't feel I get 
much out of them.


More information about the Digitalmars-d mailing list