Boost logo

Boost :

From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2007-08-20 11:23:51

On 8/20/07, David Abrahams <dave_at_[hidden]> wrote:
> on Mon Aug 20 2007, Alexander Nasonov <> wrote:
> >> 2. Unusual syntax, both for me and someone who would later work on
> >> my code. Using preprocessor sequence and having
> >> BOOST_SCOPE_EXIT_END after {} braces looks so unnatural in C++.
> >
> > Have you tried boost.lambda? I bet you will feel comfortable with
> > ScopeExit syntax after writing 10 ScopeExit bodies but mastering
> > lambda skills would take a month. I spent 5 minutes writing and
> > debugging lambda for Alternatives.ScopeGuard section but it took me
> > only 10 seconds to type ScopeExit.
> I haven't often found myself in need of something like
> ScopeGuard/ScopeExit, but I am convinced that some people find it
> indispensible. I encourage those people to give the macros a chance,
> because what Alexander says about writing lambda expressions
> definitely rings true.

I use boost lambda expression extensively, and I have a love/hate
relationship with
them. When you finally get a (complex) lambda to compile it might
even be elegant and even readable, but getting there requires an
inordinate amount of time.

I do not have time right now for a review (I will try late this
evening), but I think that the "inline" lambda capabilities of
ScopeExit and its ScopeGuard-like functionality should be decoupled.

The trick used by ScopeExit could be much more useful as a generalized
(named) closure mechanism. These closures could then be used with the
classic ScopeGuard idiom, to emulate what ScopeExit does right now,
but could also replace most usages of boost lambda.

Anyone would find such a mechanism useful? Alexander, do you think
that it would be hard to extend ScopeExit to a generalized closure? I
have done some experiments in the past with something like that and it
seemed doable.


Boost list run by bdawes at, gregod at, cpdaniel at, john at