Re: [boost] ScopeExit Review Begins Today

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. Moreover, I am convinced any lambda expression wouldn't get through our code inspection for exactly the reasons you bring up. However, I fear that I will face similar resistance to your syntax. 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 think the scope guard functionality is an essential tool for many programmers so its syntax needs to be accessible to the masses. A quick glimpse through some of the other reviews seems to indicate that I am not the only one with this concern. -Ben This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.

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
participants (2)
-
Alexander Nasonov
-
Küppers, Ben