i'd like to propose the following improvements to the clang-format:

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.


currently we get:

void foo(auto);

void bar()
{
    return foo([] { foo([] { return 0; }); });
}

void foooo(int, auto);

void baz()
{
    return foooo(0, [] {
        foo([] {
            auto x = 1 + 1;
            return x;
        });
    });

    return foooo(
            
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiint,
            [] {
                foo([] {
                    auto x = 1 + 1;
                    return x;
                });
            });
}

after the proposed changes, we'd end up with:

void foo(auto);

void bar()
{
    return foo([] {
        foo([] {
            return 0;
        });
    });
}

void foooo(int, auto);

void baz()
{
    return foooo(0, [] {
        foo([] {
            auto x = 1 + 1;
            return x;
        });
    });

    return foooo(
            
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiint,
            [] {
        foo([] {
            auto x = 1 + 1;
            return x;
        });
    });
}

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

Reply via email to