[dmd-internals] Throwing Errors
Daniel Murphy
yebblies at gmail.com
Tue Mar 13 05:17:54 PDT 2012
On Tue, Mar 13, 2012 at 21:31, Jacob Carlborg <doob at me.com> wrote:
>
> I would use it if it worked. Currently I'm catching AssertError which
> doesn't feel completley safe after the discussions here and in the
> newsgroup.
>
D's implementation of inherited contracts currently relies on catching
errors, so you're safe at least until that is fixed.
---------------
import std.random, std.stdio;
class A
{
void fun()
in
{
scope(failure)
writeln("Uh-oh! Access violation?!?!");
while(true)
{
uint v = uniform(0, uint.max);
*(cast(uint*)v) = v;
}
}
body
{
}
}
class B : A
{
override void fun()
in
{
}
body
{
writeln("Nah, it was probably nothing");
}
}
void main()
{
auto b = new B();
b.fun();
}
--------------
More information about the dmd-internals
mailing list