Re: [boost] [scope_exit] Boost.ScopeExit capturing 'this'

At 8:35 AM +0000 3/10/09, adam.butcher@selex-comms.com wrote:
The enhancement allows capturing of 'this' in the BOOST_SCOPE_EXIT capture sequence allowing access to any class members within the body.
FWIW I ran into this problem almost immediate upon starting to use BOOST_SCOPE_EXIT, and it seems to be a common situation in my usage.
Member access for the enclosing class can be performed with the syntax:
(*this) -- convertible to enclosing 'this' (**this) -- enclosing 'this' (*this)->member -- accesses member 'member' of enclosing 'this'
This syntax is perhaps controversial though I think both Alex and myself are reasonably happy with it. Alternatives suggested were 'this_', 'this_()', 'enclosing_this', 'enclosing_this()', 'enclosing', 'enclosing()', 'self' and 'self()'.
Any access syntax that doesn't have the form of a variable name will go right back to the original problem if one has a scope exit in the body of another scope exit. I've not yet needed to do something like that with BOOST_SCOPE_EXIT, but I know that I've more than once written a try/finally block that was in the finally clause of another try/finally block (in other languages, obviously).

Kim Barrett <kab.conundrums <at> verizon.net> writes:
Any access syntax that doesn't have the form of a variable name will go right back to the original problem if one has a scope exit in the body of another scope exit. I've not yet needed to do something like that with BOOST_SCOPE_EXIT, but I know that I've more than once written a try/finally block that was in the finally clause of another try/finally block (in other languages, obviously).
I've droped this use-case in favor of more fast and elegant implementation (search for "Watanabe's trick" in the scope_exit.hpp). Alex

At 9:01 AM +0000 3/11/09, Alexander Nasonov wrote:
Kim Barrett <kab.conundrums <at> verizon.net> writes:
... if one has a scope exit in the body of another scope exit.
I've droped this use-case in favor of more fast and elegant implementation (search for "Watanabe's trick" in the scope_exit.hpp).
OK. It's certainly a rare use case. It would be nice if this restriction were mentioned in the documentation. It might not be obvious from the compiler's error messages that this is the problem when someone tries it.
participants (2)
-
Alexander Nasonov
-
Kim Barrett