On Saturday, 27 November 2021 at 15:29:45 UTC, Adam D Ruppe wrote:
On Saturday, 27 November 2021 at 15:24:43 UTC, Coder wrote:
Question, why a function can not be nothrow if I catch in the body?

Ever play Pokemon? You can't just catch the cute Bulbasaur and call it done (even though the grass type is like playing on easy mode). You gotta catch 'em all!

void foo() nothrow {
    import std.utf : validate, UTFException;
    try {
        validate("a");
    }
    catch(Exception){ // make that Exception
    }
}

cuz nothrow doesn't know about specific exception types, it only looks at Exception as a whole. It doesn't actually know what validate throws.


All right, we gotta rap some pokemon like its 1998.

electro
diglet
nidoran
mankey
venosaur

Thumbs Up!

Reply via email to