Feature request: Optional, simplified syntax for simple contracts

Marco Leise Marco.Leise at gmx.de
Wed Jun 19 12:21:03 PDT 2013


I have implemented in CTFE, what I'd like asserts to look like:
http://dpaste.1azy.net/2ec082c0

It prints at runtime:

"x > y && x < 10" (x must be a digit and larger than y) failed with x: 2, y: 3
----------------
<stack trace>


When you write a contract like this:

void foo(uint x, uint y)
in { mixin(q{ x > y && x < 10 }.holds ("x must be a digit and larger than y")); }
body { … }



-- Marco



More information about the Digitalmars-d mailing list