
Alexander Nasonov wrote:
Pavel Vozenilek <pavel_vozenilek <at> hotmail.com> writes:
It is dog-slow: the small example takes over minute!!!! on Athlone XP 2200+ (no optimisations enabled).
Intel is known for being slow on heavy templatized code and its preprocessor processing is exponential.
Unless you passed a lot of variables to BOOST_FINALLY_BEGIN, it's not PP, it is Boost.Typeof that is very slow.
Mr. Alexandrescu had suggested something like that to be included in the language (as a killer feature not seen in mainstream languages). Specifically, he suggested:
on_block_exit { .... code .... } on_block_success { ... code ... } on_block_failure { ... code ... }
Cool, I didn't know this. Is there any proposal for this?
Thank you Alexander for emailing me about this thread. There isn't, at least not for C++. I convinced Walter Bright to implement the constructs in D, and helped him write this doc: http://www.digitalmars.com/d/exception-safe.html. Alexander asked me what I think of his implementation, and IMHO it is superior, and closer to intent, than our original ScopeGuard was. The fact that you can write arbitrary code inside the scope of interest, and that code has access (albeit through a less than transparent mechanism) to the local variables, is very useful for implementing exception-safe code easily and expressively. For example, the D examples in Walter's article can be easily translated into C++ (using Alexander's lib) with only little loss in terseness and clarity. Andrei