On Tue, Mar 13, 2012 at 21:31, Jacob Carlborg <[email protected]> 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();
}

--------------
_______________________________________________
dmd-internals mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/dmd-internals

Reply via email to