Re: [webkit-dev] [Styling] () for a lambda without arguments (Was Space between [] and () in C++ lambdas)

2019-11-08 Thread Ryosuke Niwa
Seems like there is a consensus here. Here's a patch to codify it in our
code style guidelines: https://bugs.webkit.org/show_bug.cgi?id=204021

On Mon, Nov 4, 2019 at 8:06 AM Alex Christensen 
wrote:

> When the lambda is mutable or has a trailing return type, the () is
> currently required by the C++ grammar, so we can’t say to always omit ().
> We could say to always have it, to only have it when necessary, or have no
> code style guideline.  I think we should always have spaces before and
> after, though.
>
> On Nov 3, 2019, at 3:27 AM, Ryosuke Niwa  wrote:
>
>
>
> On Sat, Nov 2, 2019 at 8:25 PM Ryosuke Niwa  wrote:
>
>>
>> On Sat, Nov 2, 2019 at 7:54 PM Chris Dumez  wrote:
>>
>>>
>>>
>>> On Nov 2, 2019, at 7:38 PM, Ryosuke Niwa  wrote:
>>>
>>> 
>>>
>>> On Sat, Nov 2, 2019 at 1:23 AM Antti Koivisto  wrote:
>>>

 On Sat, Nov 2, 2019 at 1:38 AM Ryosuke Niwa  wrote:

> On Fri, Nov 1, 2019 at 11:53 AM Michael Catanzaro <
> mcatanz...@gnome.org> wrote:
>
>> On Fri, Nov 1, 2019 at 11:19 am, Ryosuke Niwa 
>> 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.
>>
>
> I guess that's another thing we should decide. Should we, or should we
> not have () when there are no arguments.
>

 I think this is easily settled by voting via exiting practice. We have
 1287 instances of [&] { and 107 instances of [&]() { and &] () { across the
 whole WebKit.

>>>
>>> That’s good to know. Why don’t we go with the status quo then.
>>>
>>> In this case, we do put a space between ] or ) and {, right?
>>>
>>>
>>> How is this the conclusion from Antti’s comment?
>>>
>>> Based on the discussion so far, it thought no space had a slight lead.
>>>
>>
>> I think you’re conflating this discussion with the other email thread
>> about a space between [] and ().
>>
>> Here, I’m talking about placing a space after [] before { as in:
>> [] { }
>>
>> As opposed to:
>> []{ }
>>
>> We never use the latter style whether it’s other control flow statements
>> like if, while, or for, or for function definitions.
>>
>> - R. Niwa
>>
>> --
>> - R. Niwa
>>
> --
> - R. Niwa
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
>
>
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] [Styling] () for a lambda without arguments (Was Space between [] and () in C++ lambdas)

2019-11-04 Thread Alex Christensen
When the lambda is mutable or has a trailing return type, the () is currently 
required by the C++ grammar, so we can’t say to always omit ().  We could say 
to always have it, to only have it when necessary, or have no code style 
guideline.  I think we should always have spaces before and after, though.

> On Nov 3, 2019, at 3:27 AM, Ryosuke Niwa  wrote:
> 
> 
> 
> On Sat, Nov 2, 2019 at 8:25 PM Ryosuke Niwa  > wrote:
> 
> On Sat, Nov 2, 2019 at 7:54 PM Chris Dumez  > wrote:
> 
> 
>> On Nov 2, 2019, at 7:38 PM, Ryosuke Niwa > > wrote:
>> 
>> 
>> 
>> On Sat, Nov 2, 2019 at 1:23 AM Antti Koivisto > > wrote:
>> 
>> On Sat, Nov 2, 2019 at 1:38 AM Ryosuke Niwa > > wrote:
>> On Fri, Nov 1, 2019 at 11:53 AM Michael Catanzaro > > wrote:
>> On Fri, Nov 1, 2019 at 11:19 am, Ryosuke Niwa > > 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.
>> 
>> I guess that's another thing we should decide. Should we, or should we not 
>> have () when there are no arguments.
>> 
>> I think this is easily settled by voting via exiting practice. We have 1287 
>> instances of [&] { and 107 instances of [&]() { and &] () { across the whole 
>> WebKit.
>> 
>> That’s good to know. Why don’t we go with the status quo then.
>> 
>> In this case, we do put a space between ] or ) and {, right?
> 
> How is this the conclusion from Antti’s comment?
> 
> Based on the discussion so far, it thought no space had a slight lead.
> 
> I think you’re conflating this discussion with the other email thread about a 
> space between [] and ().
> 
> Here, I’m talking about placing a space after [] before { as in:
> [] { }
> 
> As opposed to:
> []{ }
> 
> We never use the latter style whether it’s other control flow statements like 
> if, while, or for, or for function definitions.
> 
> - R. Niwa
> 
> -- 
> - R. Niwa
> -- 
> - R. Niwa
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org 
> https://lists.webkit.org/mailman/listinfo/webkit-dev 
> 
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] [Styling] () for a lambda without arguments (Was Space between [] and () in C++ lambdas)

2019-11-02 Thread Ryosuke Niwa
On Sat, Nov 2, 2019 at 8:25 PM Ryosuke Niwa  wrote:

>
> On Sat, Nov 2, 2019 at 7:54 PM Chris Dumez  wrote:
>
>>
>>
>> On Nov 2, 2019, at 7:38 PM, Ryosuke Niwa  wrote:
>>
>> 
>>
>> On Sat, Nov 2, 2019 at 1:23 AM Antti Koivisto  wrote:
>>
>>>
>>> On Sat, Nov 2, 2019 at 1:38 AM Ryosuke Niwa  wrote:
>>>
 On Fri, Nov 1, 2019 at 11:53 AM Michael Catanzaro 
 wrote:

> On Fri, Nov 1, 2019 at 11:19 am, Ryosuke Niwa 
> 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.
>

 I guess that's another thing we should decide. Should we, or should we
 not have () when there are no arguments.

>>>
>>> I think this is easily settled by voting via exiting practice. We have
>>> 1287 instances of [&] { and 107 instances of [&]() { and &] () { across the
>>> whole WebKit.
>>>
>>
>> That’s good to know. Why don’t we go with the status quo then.
>>
>> In this case, we do put a space between ] or ) and {, right?
>>
>>
>> How is this the conclusion from Antti’s comment?
>>
>> Based on the discussion so far, it thought no space had a slight lead.
>>
>
> I think you’re conflating this discussion with the other email thread
> about a space between [] and ().
>
> Here, I’m talking about placing a space after [] before { as in:
> [] { }
>
> As opposed to:
> []{ }
>
> We never use the latter style whether it’s other control flow statements
> like if, while, or for, or for function definitions.
>
> - R. Niwa
>
> --
> - R. Niwa
>
-- 
- R. Niwa
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] [Styling] () for a lambda without arguments (Was Space between [] and () in C++ lambdas)

2019-11-02 Thread Chris Dumez


> On Nov 2, 2019, at 7:38 PM, Ryosuke Niwa  wrote:
> 
> 
> 
>> On Sat, Nov 2, 2019 at 1:23 AM Antti Koivisto  wrote:
>> 
>>> On Sat, Nov 2, 2019 at 1:38 AM Ryosuke Niwa  wrote:
 On Fri, Nov 1, 2019 at 11:53 AM Michael Catanzaro  
 wrote:
>>> 
 On Fri, Nov 1, 2019 at 11:19 am, Ryosuke Niwa  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.
>>> 
>>> I guess that's another thing we should decide. Should we, or should we not 
>>> have () when there are no arguments.
>> 
>> I think this is easily settled by voting via exiting practice. We have 1287 
>> instances of [&] { and 107 instances of [&]() { and &] () { across the whole 
>> WebKit.
> 
> That’s good to know. Why don’t we go with the status quo then.
> 
> In this case, we do put a space between ] or ) and {, right?

How is this the conclusion from Antti’s comment?

Based on the discussion so far, it thought no space had a slight lead.

> 
> I guess this is also consistent with the way people write objective C blocks: 
> https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html
> 
> For JavaScript, this rule probably doesn’t apply because arrow function and 
> regular anonymous function both require ().
> 
> - R. Niwa
> 
> -- 
> - R. Niwa
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] [Styling] () for a lambda without arguments (Was Space between [] and () in C++ lambdas)

2019-11-02 Thread Ryosuke Niwa
On Sat, Nov 2, 2019 at 1:23 AM Antti Koivisto  wrote:

>
> On Sat, Nov 2, 2019 at 1:38 AM Ryosuke Niwa  wrote:
>
>> On Fri, Nov 1, 2019 at 11:53 AM Michael Catanzaro 
>> wrote:
>>
>>> On Fri, Nov 1, 2019 at 11:19 am, Ryosuke Niwa  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.
>>>
>>
>> I guess that's another thing we should decide. Should we, or should we
>> not have () when there are no arguments.
>>
>
> I think this is easily settled by voting via exiting practice. We have
> 1287 instances of [&] { and 107 instances of [&]() { and &] () { across the
> whole WebKit.
>

That’s good to know. Why don’t we go with the status quo then.

In this case, we do put a space between ] or ) and {, right?

I guess this is also consistent with the way people write objective C
blocks:
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html

For JavaScript, this rule probably doesn’t apply because arrow function and
regular anonymous function both require ().

- R. Niwa

-- 
- R. Niwa
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] [Styling] () for a lambda without arguments (Was Space between [] and () in C++ lambdas)

2019-11-01 Thread Zalan Bujtas
I've been using the short form in the layout code for a while now and never
mistaken it for code block start & end.
That being said I don't have strong preference on this.

Alan.

On Fri, Nov 1, 2019 at 4:37 PM Ryosuke Niwa  wrote:

> On Fri, Nov 1, 2019 at 11:53 AM Michael Catanzaro 
> wrote:
>
>> On Fri, Nov 1, 2019 at 11:19 am, Ryosuke Niwa  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.
>>
>
> I guess that's another thing we should decide. Should we, or should we not
> have () when there are no arguments.
>
> I think we usually err on the side of more concise form but I do prefer
> having () so that it's clear it's a function. Otherwise, it can look like a
> code block start & end.
>
> - R. Niwa
>
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev