assume, assert, enforce, @safe
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Fri Aug 1 16:59:29 PDT 2014
On 08/02/2014 01:46 AM, H. S. Teoh via Digitalmars-d wrote:
> OTOH, perhaps one way to work around this, is to have a function with an
> in-contract compile into a preamble and a body:
>
> int func(int x)
> in { assert(x > 5); }
> body {
> return computeResult(x);
> }
>
> would compile to the equivalent of:
>
> int __func_incontract(int x) {
> assert(x > 5);
> goto __func_body; // fall through to __func_body
> }
> int __func_body(int x) {
> return computeResult(x);
> }
>
> In non-release mode, calls to func would get translated into calls to
> __func_incontract,
What if a library function was compiled in release mode?
More information about the Digitalmars-d
mailing list