>> 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.

> single-line lambdas can look a bit more compact and may look nicer when
> reading code. but the more complex / higher order the codebase, the more
> harmful it gets (my past self often ended up recompiling code just in
> order to set breakpoints)

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.

In my view (not a strong opinion),  having only multiline lambdas cannot be 
turned into a strict rule. A line with complex logic should definitely be 
separated, but in simple cases, it's more of a style and responsibility of the 
code author to decide whether it's important to separate.

Regards, Artem


Confidential
________________________________
From: Tim Blechmann <[email protected]>
Sent: Wednesday, October 8, 2025 6:57 AM
To: Macieira, Thiago <[email protected]>; [email protected] 
<[email protected]>
Subject: Re: [Development] proposed clang-format improvements for lambda 
functions

>> AllowShortLambdasOnASingleLine: None
>> LambdaBodyIndentation: OuterScope
>>
>> rationale:
>> * single-line lambda functions are harmful, as one cannot set different
>> breakpoints for construction and invocation of the lambda function.
>> * indent lambda bodies at the outer scope, so that the indentation
>> reflects the nesting level.
>
> 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.

single-line lambdas can look a bit more compact and may look nicer when
reading code. but the more complex / higher order the codebase, the more
harmful it gets (my past self often ended up recompiling code just in
order to set breakpoints)

> I'm not sure I understand the second. More importantly, though: does Qt
> Creator have a setting for that? If so, what it is? If not, then DOA.

when using the "built in formatter" instead of the clang-format
formatter, lambda bodies are indented at the outer scope as well. there
is no option in the built-in formatter to disable, it (the clang-format
formatter would use the clang-format file when present or can be
configured with a everything that clang-format supports)


-- 
Development mailing list
[email protected]
https://lists.qt-project.org/listinfo/development

Reply via email to