Hacker News new | ask | show | jobs
by Garoof 4881 days ago
So, on a "some other language does like so" note, in D you might write it kind of like this:

    allocate_memory();
    scope(failure) free_memory();
    setup_interrupts();
    scope(failure) teardown_interrupts();
    setup_registers();
The scope keyword is for saying that if you get to this point, then do such and such at end of scope. scope(failure)/scope(success)/scope(exit), for exitting scope by exception/return/either. Is kind of nice.