3 ms·
Yes, but they are guaranteed to run at the beginning and end. C/C++ asserts need to handle any return path, whereas D has functionality to mark statements to ru
by LorenDB 1y ago
Yes, but they are guaranteed to run at the beginning and end. C/C++ asserts need to handle any return path, whereas D has functionality to mark statements to run at the end of any return path while only being written once.
See also the scope(exit) feature.
- almostgotcaught 1y agoYou can accomplish the same exact thing with https://en.cppreference.com/w/cpp/experimental/scope_exit.html https://en.cppreference.com/w/cpp/experimental/scope_exit.ht...
- WalterBright 1y agoThe idea for scope-exit came from Andrei Alexandrescu. See https://dlang.org/articles/exception-safe.html https://dlang.org/articles/exception-safe.html He demonstrated it with C++ templates, but the D one is far more straightforward.