[Development] proposed clang-format improvements for lambda functions

Tim Blechmann tim.blechmann at qt.io
Fri Oct 10 02:33:50 CEST 2025


>  >> I kind of like single-line lambdas, but I understand not doing them for
>  >> breakpoint purposes. Still, we may want them for simple parameters. 
> That's a
>  >> stylistic choice.
> 
> + 1 who also likes single-line lambdas that are doing a simple job 
> (e.g., returning a constant value or further call propagating to a 
> defined function).
> E.g., one writes code:
> foo(boolArg),
>   Then they replace the parameter with
> foo(predicate),
>   and then handles the simplest case, e.g:
> foo([](){ return true; })
> I don't see a reason for making it multiline.

there are cases when one wants to check if the predicate is actually 
called. today's developer does not necessarily know where tomorrow's 
developer may want to set a breakpoint in a specific codepath.

> During my practice in Qt, I didn't encounter "harmful" cases. Maybe it's 
> because I prefer setting breakpoints only in the target places, and 
> single-line lambdas often do not represent the target ones.

if there is only one caller, setting a breakpoint at the target is 
feasible, but it is highly depending on the complexity of the code in 
question: my former self ran into many situations where a specific 
"target" is called from many "sources", and simply adding a breakpoint 
at the target was not sufficient.

--

of course one can always recompile code when trying to debug some 
specific code, but that is what what i consider as "harmful", because it 
increases the latency of compile/debug iterations (when building for 
desktop this is in the seconds, when building for embedded and involves 
deployment to devices, this can easily be in the minutes).

it basically boils down to the question: do we want code that is nicer 
to read or nicer to debug :)



More information about the Development mailing list