assume, assert, enforce, @safe

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 1 16:19:06 PDT 2014


On Friday, 1 August 2014 at 23:13:28 UTC, H. S. Teoh via 
Digitalmars-d wrote:

> IMO the correct solution is for the compiler to insert 
> preconditions at the calling site, rather than the callee.

If we had that, I'd actually start using in blocks. As it is, I 
think that they're useless except when inheritance is involved, 
and they're more verbose than just putting the assertions at the 
top of the function, so I don't bother with the in block.

But certainly, in principle, I agree that whether contracts are 
used would depend on the flags used when compiler the caller, not 
the callee, but the separate compilation model does throw some 
kinks in that. But even if it just worked in cases where the 
source code was available, it would be an improvement.

- Jonathan M Davis


More information about the Digitalmars-d mailing list