http://d.puremagic.com/issues/show_bug.cgi?id=6278



--- Comment #7 from Michel Fortin <michel.for...@michelf.com> 2011-07-10 
08:21:02 EDT ---
> Only the overridden contracts would throw ContractExceptions, the only way you
> would ever see them was if you did:
> [...]
> Which is just horrible.

But it would be legal, even in safe code. And it'd be inconsistent since it'd
work only in overriding contracts and not elsewhere, exposing an implementation
detail.

(And it has nothing to do with this bug. I think you should fill a bug about
other errors being caught by contracts and discuss all this there.)

> If we disallow scope(exit/failure) and try/catch inside in contracts assert(x)
> could be re-written to if (!x) goto contractfail; which bypasses exceptions
> altogether.

Wouldn't that lead to other problems? If you had a struct with a destructor as
a local variable inside your contract, that destructor will be called in an
implicit finally block, much like scope(exit), so disabling try/finally will
break that.

Beside, what do we gain by disabling this? I agree it'd a poor coding practice
to catch exceptions in contracts, but I don't think the language should try to
enforce that. It might even be useful if for some reason you need to debug your
contract.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to