Anyway the solution with lambdas or this one rarely do not need curly braces. I have written that code in c# - the C language family simply do not suit for lambdas inside lambdas inside lambdas style. And the proposed solution leads to similar style. With anonymous variables we may not need new pair of braces.
Regards,
Gregory
Le 28/11/12 20:42, grigor...@gmail.com a �crit :
Sorry for incoherence.On fixing lambdas. For example, we could allow single expression lambdas to be declared without curly braces. That would give us most of the benefits that let-in bindings give us.It will be a little bit more noisy, but much. Considersynchronized(mt, []() .... );Or another variant:synchronized(mt) << [] () ..... ;On the style. The solutions with lambdas or let-in bindings instead of pure RAII have a drawback, that there appears to be a lot more braces than in pure RAII, which results in syntactic noise.Imagine you need 3 or 4 RAII objects in the function. So, you create let binding for the first, then inside it create let binding for the second and so on...And now the code is much less readable.
With RAII you sometimes need to put additional braces, and sometimes it looks ugly, but IMHO with let-bindings everywhere code would be much more ugly than without them.
Sorry for incoherence.
On fixing lambdas. For example, we could allow single expression lambdas to be declared without curly braces. That would give us most of the benefits that let-in bindings give us.It will be a little bit more noisy, but much. Considersynchronized(mt, []() .... );Or another variant:synchronized(mt) << [] () ..... ;