D is dead
Jonathan M Davis
newsgroup.d at jmdavisprog.com
Sat Sep 1 14:44:19 UTC 2018
On Saturday, September 1, 2018 8:31:36 AM MDT H. S. Teoh via Digitalmars-d
wrote:
> This change may also address the current hackish implementation of
> subclass contracts (which involves catching Errors, an arguably
> dangerous thing to do), though I'm not 100% sure.
AFAIK, there's absolutely nothing required to fix that other than just
implementing it. As I understand it, the assertions act normally and thus
throw AssertErrors, but there should be no technical reason why they
couldn't be transformed into something else. e.g.
in
{
assert(foo < 7);
}
could be lowered to something like
in
{
if(foo < 7)
return false;
return true;
}
The only differences would then be if any functions called in the contract
resulted in an AssertError (sinc that would no longer count as a contract
failure - which is arguably a bug fix) and that explicitly throwing an
AssertError wouldn't work anymore - but I expect that that's rare enough
that it wouldn't be all that big a deal.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list