Simply, it should be replaced by:

void safeFunc() @safe {
    unsafe {
        auto vi = doUnsafeCall();
    }
}

@trusted functions are prohibited by d-idiom (so I don't know why are still in D). So, when I need to create a simple window with OpenGL context I need to write about 10-15 calls to system functions. But D-idiom[1] for @trusted tells me to make @trusted functions as small as possible. OK, it makes sense.

but writing 20 times something like:
auto vi = (() @trusted => glXChooseXFBConfig(...))();

or:
auto vi = () @trusted { return glXChooseXFBConfig(...); }();

is annoying and just forced me to mark whole class with @trusted...



[1] https://dlang.org/blog/2016/09/28/how-to-write-trusted-code-in-d/

Reply via email to