Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This seems equivalent to scope(exit)/scope(success)/scope(failure) in D. The drawback of this construct is that you need to repeat 2 or 3 lines of code each time you need safe cleanup or a commit/abort type of construct. This can become pretty repetitive pretty fast.


I wish D had copied pythons with statement (without the scope escape) and not used the with statement for destructuring.

The nicest thing: you can throw in the exit method without the runtime falling over itself.


I totally missed that Python has this. This seems like the saner sibling of C#'s using/IDisposable construct.

You can do a kind of RAII in D when you use structs instead of classes because these are stack allocated and have a suitable lifetime.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: