|
Boost : |
From: Alexander Nasonov (alnsn_at_[hidden])
Date: 2007-08-20 09:42:03
Küppers, Ben <ben.kuppers <at> logicacmg.com> writes:
> Alexander,
>
> I understand your gripes about the lambda syntax, but to be perfectly frank,
> I have never used lambda expressions in combination with the scope guard
> (which is maybe why your arguments have so far been unable to convince me).
> My clean up actions tend to be trivial function calls or functors that don't
> require any lambda syntax.
That's probably because you never needed a strong exception safety guarantee
in your code. People rarely care about it (some don't care about exception
safety at all!) but there are times when your function should execute all or
nothing. In this case, your scope guard action would contain at least one
branch if_(!var(commit)) [ ... rollback action ... ].
I could implement ScopeGuard with conditional execution but conditions are
often more complex than a reference to some bool variable. Some actions
may even contain loops or other patterns.
> It's hard to argue that a macro with (seemingly) un-typed arguments, a code
> block between curly braces followed by another macro, look anything like C++
> (and arguing its correctness based on a future language standard probably
> won't do me much good either).
I agree that it looks strange when you see it first time but it's very easy to
get used to this construct.
> I think the scope guard functionality is an essential tool for many
> programmers so its syntax needs to be accessible to the masses.
It's already in boost::detail. I wonder why nobody has submitted it
for fast-track review. May be it's a sign of scope guard weaknesses?
-- Alexander
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk