[webkit-dev] [Styling] Space between [] and () in C++ lambdas

Caitlin Potter caitp at igalia.com
Sat Nov 2 10:16:10 PDT 2019


Not that anybody asked me, but I also prefer to not include a space between captures and parameter, for similar reasons.

If I’m not mistaken, v8/chromium tends to omit the space as well. If that’s still true and WebKit adopted that style, context switching between both codebases would be marginally easier for me.

> On Nov 2, 2019, at 4:19 AM, Antti Koivisto <koivisto at iki.fi> wrote:
> 
> 
>> On Fri, Nov 1, 2019 at 10:50 PM Yusuke Suzuki <ysuzuki at apple.com> wrote:
>> 
>> > On Nov 1, 2019, at 11:53, Michael Catanzaro <mcatanzaro at gnome.org> wrote:
>> > 
>> > On Fri, Nov 1, 2019 at 11:19 am, Ryosuke Niwa <rniwa at webkit.org> wrote:
>> >> Namely, some people write a lambda as:
>> >> auto x = [] () { }
>> >> with a space between [] and () while others would write it as:
>> >> auto x = []() { }
>> > 
>> > ��: I omit the () when there are no parameters, as in these examples.
>> > 
>> > No preference on spacing.
>> 
>> I like having a space here, because this rule is simpler to me.
>> If we always have a space between them, this is clear that the above case is written in `[] { }` instead of `[]{ }`.
> 
> I prefer not having the redundant space in [](). It also makes logical sense to me to keep the lambda signature together. I started using lambdas with space there, dropped it later, and suffered no adverse consequences.
> 
> As for existing practice, WebCore favors spaceless ]( about 2:1 but across the entire WebKit it is closer to 1:1.
> 
> We always put space before { } block, I don't think that is really in question here, or creating any inconsistencies.
> 
> 
>    antti
>  
>> 
>> -Yusuke
>> 
>> > 
>> > 
>> > _______________________________________________
>> > webkit-dev mailing list
>> > webkit-dev at lists.webkit.org
>> > https://lists.webkit.org/mailman/listinfo/webkit-dev
>> 
>> _______________________________________________
>> webkit-dev mailing list
>> webkit-dev at lists.webkit.org
>> https://lists.webkit.org/mailman/listinfo/webkit-dev
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20191102/03a7b641/attachment.htm>


More information about the webkit-dev mailing list