Feature request: Optional, simplified syntax for simple contracts
Marco Leise
Marco.Leise at gmx.de
Sun Jun 16 08:45:20 PDT 2013
Am Sun, 16 Jun 2013 04:22:59 +0200
schrieb "TommiT" <tommitissari at hotmail.com>:
> On Sunday, 16 June 2013 at 00:19:37 UTC, Manu wrote:
> > Super awesome idea! How about coma separated expressions to
> > perform
> > multiple asserts?
> >
> > int func(int i, int j) in(i<5, j<10)
> > {
> > return i + j;
> > }
>
> Do you mean ...to get more specific error messages than with
> in(i<5 && j<10) ?
Actually these are 2 great ideas. Make that expand to:
in {
assert(i<5, __FUNCTION__ ~ ": precondition i<5 failed. Variables: i == " ~ to!string(i));
assert(j<10, __FUNCTION__ ~ ": precondition j<10 failed. Variables: j == " ~ to!string(j));
}
--
Marco
More information about the Digitalmars-d
mailing list