[prev in list] [next in list] [prev in thread] [next in thread] 

List:       webkit-dev
Subject:    Re: [webkit-dev] [Styling] () for a lambda without arguments (Was Space between [] and () in C++ lam
From:       Alex Christensen <achristensen () apple ! com>
Date:       2019-11-04 16:05:50
Message-ID: D09E0097-72F3-4AF3-924B-38909EE2B511 () apple ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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 <rniwa@webkit.org> wrote:
> 
> 
> 
> On Sat, Nov 2, 2019 at 8:25 PM Ryosuke Niwa <rniwa@webkit.org \
> <mailto:rniwa@webkit.org>> wrote: 
> On Sat, Nov 2, 2019 at 7:54 PM Chris Dumez <cdumez@apple.com \
> <mailto:cdumez@apple.com>> wrote: 
> 
> > On Nov 2, 2019, at 7:38 PM, Ryosuke Niwa <rniwa@webkit.org \
> > <mailto:rniwa@webkit.org>> wrote: 
> > 
> > 
> > On Sat, Nov 2, 2019 at 1:23 AM Antti Koivisto <koivisto@iki.fi \
> > <mailto:koivisto@iki.fi>> wrote: 
> > On Sat, Nov 2, 2019 at 1:38 AM Ryosuke Niwa <rniwa@webkit.org \
> > <mailto:rniwa@webkit.org>> wrote: On Fri, Nov 1, 2019 at 11:53 AM Michael \
> > Catanzaro <mcatanzaro@gnome.org <mailto:mcatanzaro@gnome.org>> wrote: On Fri, Nov \
> > 1, 2019 at 11:19 am, Ryosuke Niwa <rniwa@webkit.org <mailto:rniwa@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.
> > 
> > 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 <mailto:webkit-dev@lists.webkit.org>
> https://lists.webkit.org/mailman/listinfo/webkit-dev \
> <https://lists.webkit.org/mailman/listinfo/webkit-dev>


[Attachment #5 (unknown)]

<html><head><meta http-equiv="Content-Type" content="text/html; \
charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; \
line-break: after-white-space;" class="">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 (). &nbsp;We could say to always have it, to only have it when necessary, \
or have no code style guideline. &nbsp;I think we should always have spaces before \
and after, though.<br class=""><div><br class=""><blockquote type="cite" \
class=""><div class="">On Nov 3, 2019, at 3:27 AM, Ryosuke Niwa &lt;<a \
href="mailto:rniwa@webkit.org" class="">rniwa@webkit.org</a>&gt; wrote:</div><br \
class="Apple-interchange-newline"><div class=""><div style="caret-color: rgb(0, 0, \
0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: \
normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: \
0px; text-transform: none; white-space: normal; word-spacing: 0px; \
-webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br \
class="Apple-interchange-newline"><br class=""><div class="gmail_quote"><div \
dir="ltr" class="gmail_attr">On Sat, Nov 2, 2019 at 8:25 PM Ryosuke Niwa &lt;<a \
href="mailto:rniwa@webkit.org" class="">rniwa@webkit.org</a>&gt; wrote:<br \
class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; \
border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, \
204); padding-left: 1ex;"><div class=""><br class=""></div><div class=""><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Nov 2, 2019 at 7:54 PM \
Chris Dumez &lt;<a href="mailto:cdumez@apple.com" target="_blank" \
class="">cdumez@apple.com</a>&gt; wrote:<br class=""></div><blockquote \
class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; \
border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: \
1ex;"><div dir="auto" class=""><br class=""><div dir="ltr" class=""><br \
class=""><blockquote type="cite" class="">On Nov 2, 2019, at 7:38 PM, Ryosuke Niwa \
&lt;<a href="mailto:rniwa@webkit.org" target="_blank" \
class="">rniwa@webkit.org</a>&gt; wrote:<br class=""><br \
class=""></blockquote></div><blockquote type="cite" class=""><div dir="ltr" \
class=""><div class=""><br class=""></div><div class=""><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Nov 2, 2019 at 1:23 AM \
Antti Koivisto &lt;<a href="mailto:koivisto@iki.fi" target="_blank" \
class="">koivisto@iki.fi</a>&gt; wrote:<br class=""></div><blockquote \
class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; \
border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: \
1ex;"><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><br \
class=""></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Nov \
2, 2019 at 1:38 AM Ryosuke Niwa &lt;<a href="mailto:rniwa@webkit.org" target="_blank" \
class="">rniwa@webkit.org</a>&gt; wrote:<br class=""></div><blockquote \
class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; \
border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: \
1ex;"><div dir="ltr" class=""><div dir="ltr" class="">On Fri, Nov 1, 2019 at 11:53 AM \
Michael Catanzaro &lt;<a href="mailto:mcatanzaro@gnome.org" target="_blank" \
class="">mcatanzaro@gnome.org</a>&gt; wrote:<br class=""></div><div \
class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; \
border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, \
204); padding-left: 1ex;">On Fri, Nov 1, 2019 at 11:19 am, Ryosuke Niwa &lt;<a \
href="mailto:rniwa@webkit.org" target="_blank" class="">rniwa@webkit.org</a>&gt; \
wrote:<br class="">&gt; Namely, some people write a lambda as:<br class="">&gt; auto \
x = [] () { }<br class="">&gt;<span class="Apple-converted-space">&nbsp;</span><br \
class="">&gt; with a space between [] and () while others would write it as:<br \
class="">&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">&gt; auto \
x = []() { }<br class=""><br class="">🔧: I omit the () when there are no \
parameters, as in these examples.<br class=""></blockquote><div class=""><br \
class=""></div><div class="">I guess that's another thing we should decide. Should \
we, or should we not have () when there are no \
arguments.</div></div></div></blockquote><div class=""><br class=""></div><div \
class="">I think this is easily settled by voting via exiting practice. We have 1287 \
instances of [&amp;] { and 107 instances&nbsp;of [&amp;]() { and&nbsp;&amp;] () { \
across the whole WebKit.</div></div></div></div></blockquote><div dir="auto" \
class=""><br class=""></div><div dir="auto" class="">That's good to know. Why don't \
we go with the status quo then.</div><div dir="auto" class=""><br class=""></div><div \
dir="auto" class="">In this case, we do put a space between ] or ) and {, \
right?</div></div></div></div></blockquote><div class=""><br class=""></div><div \
class="">How is this the conclusion from Antti's comment?</div><div class=""><br \
class=""></div><div class="">Based on the discussion so far, it thought no space had \
a slight lead.</div></div></blockquote><div dir="auto" class=""><br \
class=""></div><div dir="auto" class="">I think you're conflating this discussion \
with the other email thread about a space between [] and ().</div><div dir="auto" \
class=""><br class=""></div><div dir="auto" class="">Here, I'm talking about placing \
a space after [] before { as in:</div><div dir="auto" class="">[] { }</div><div \
dir="auto" class=""><br class=""></div><div dir="auto" class="">As opposed \
to:</div><div dir="auto" class="">[]{ }</div><div dir="auto" class=""><br \
class=""></div><div dir="auto" class="">We never use the latter style whether it's \
other control flow statements like if, while, or for, or for function \
definitions.</div><div dir="auto" class=""><br class=""></div><div dir="auto" \
class="">- R. Niwa</div></div></div><div class=""><div class="gmail_quote"><div \
dir="auto" class=""><br class=""></div></div></div>--<span \
class="Apple-converted-space">&nbsp;</span><br class=""><div dir="ltr" \
data-smartmail="gmail_signature" class="">- R. \
Niwa</div></blockquote></div></div><span style="caret-color: rgb(0, 0, 0); \
font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: \
normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: \
0px; text-transform: none; white-space: normal; word-spacing: 0px; \
-webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline \
!important;" class="">--<span class="Apple-converted-space">&nbsp;</span></span><br \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" \
class=""><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature" \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">- \
R. Niwa</div><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; \
font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; \
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; \
white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; \
text-decoration: none; float: none; display: inline !important;" \
class="">_______________________________________________</span><br \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" \
class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: \
12px; font-style: normal; font-variant-caps: normal; font-weight: normal; \
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; \
white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; \
text-decoration: none; float: none; display: inline !important;" class="">webkit-dev \
mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; \
font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; \
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; \
white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; \
text-decoration: none;" class=""><a href="mailto:webkit-dev@lists.webkit.org" \
style="font-family: Helvetica; font-size: 12px; font-style: normal; \
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: \
auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; \
widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; \
-webkit-text-stroke-width: 0px;" class="">webkit-dev@lists.webkit.org</a><br \
style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; \
font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: \
normal; text-align: start; text-indent: 0px; text-transform: none; white-space: \
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" \
class=""><a href="https://lists.webkit.org/mailman/listinfo/webkit-dev" \
style="font-family: Helvetica; font-size: 12px; font-style: normal; \
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: \
auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; \
widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; \
-webkit-text-stroke-width: 0px;" \
class="">https://lists.webkit.org/mailman/listinfo/webkit-dev</a></div></blockquote></div><br \
class=""></body></html>



_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic