On Sunday, 26 July 2015 at 11:38:31 UTC, simendsjo wrote:
Is there a reason why you would hide the fact that a function is trusted rather than safe? Technically it doesn't matter, right? To me, it seems like this would give wrong assumptions to the caller.

The reason I ask is because I found the following in std.concurrency:

    @property Tid thisTid() @safe
    {
        // TODO: remove when concurrency is safe
        auto trus = delegate() @trusted
        {
            if( thisInfo.ident != Tid.init )
                return thisInfo.ident;
            thisInfo.ident = Tid( new MessageBox );
            return thisInfo.ident;
        };

        return trus();
    }

As far as I know, it doesn't matter. Both @safe and @trusted functions must be memory safe. So I don't see a point in doing that delegate dance.

But it doesn't make a difference to the caller either. They can't assume any more or less about an @safe function than about an @trusted one.

Reply via email to