<div dir="ltr">Dear folks<div><br></div><div>The choice between</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>[&capture1, capture2] (Type1 arg1, Type2 arg2)</div></div><div><div>{</div></div><div><div>  statements;</div></div><div><div>}</div></div></blockquote><div>and</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>[&capture1, capture2] (Type1 arg1, Type2 arg2) {</div></div><div><div>  statements;</div></div><div><div>}</div></div></blockquote><div>depends on whether a lambda expression is more like a function, or a block statement (similar to if/for/while).</div><div>A lambda expression is an inline function and rule 1.5 mandates the first style for functions.</div><div>Another possible understanding is: put "{" on the next line for everything down to named function level, and put "{" on the same line for everything inside a named function. This makes the second style preferred.</div><div>What do others on nfd-dev think?</div><div><br></div><div><br></div><div>`auto` specifier can be used to declare variables at any scope: block scope, namespace scope, init statement of for loop.</div><div>The proposed rule is to forbid using `auto` specifier at namespace scope, because such usage makes the code less readable.</div><div><br></div><div>Yours, Junxiao</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 2, 2014 at 1:03 PM, Alex Afanasyev <span dir="ltr"><<a href="mailto:alexander.afanasyev@ucla.edu" target="_blank">alexander.afanasyev@ucla.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><blockquote type="cite"><div>On Nov 2, 2014, at 9:20 AM, Junxiao Shi <<a href="mailto:shijunxiao@email.arizona.edu" target="_blank">shijunxiao@email.arizona.edu</a>> wrote:</div><br><div><div dir="ltr">Dear folks<div><br></div><div>We need to define some new code style rules for C++11 syntax.</div><div><br></div><div>I'd start with three new rules:</div><div><br></div><div>rule x. Range-based for should be in the following form:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>for (auto i : range) {</div><div>  statements;</div><div>}</div></blockquote><div><br></div><div><br></div><div>rule x. Lambda expression should be in the following form:</div><div><br></div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>[&capture1, capture2] (Type1 arg1, Type2 arg2)</div><div>{</div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>  statements;</div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>}</div></blockquote></div></div></div></blockquote><div><br></div></span><div>I prefer different style, which more aligns with the existing code (and is more gnu style):</div><span class=""><div><br></div><div>[&capture1, capture2] (Type1 arg1, Type2 arg2) {<br>  statements;<br>}</div><br><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>If the function body has only one line, and the whole expression can fit in one line, the following form is also acceptable:</div><div><br></div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>[&capture1, capture2] (Type1 arg1, Type2 arg2) { statement; }</div></blockquote></div></div></div></blockquote><div><br></div></span><div>that’s fine too</div><span class=""><br><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>rule x. `auto` type should only be used for local variables.</div></div></div></blockquote><div><br></div></span><div>Where else, potentially, it can be used?</div><br><blockquote type="cite"><div><span class=""><div dir="ltr"><div><br></div><div>What other rules do we need?</div><div><br></div><div>Yours, Junxiao</div></div></span>
_______________________________________________<br>Nfd-dev mailing list<br><a href="mailto:Nfd-dev@lists.cs.ucla.edu" target="_blank">Nfd-dev@lists.cs.ucla.edu</a><br><a href="http://www.lists.cs.ucla.edu/mailman/listinfo/nfd-dev" target="_blank">http://www.lists.cs.ucla.edu/mailman/listinfo/nfd-dev</a><br></div></blockquote></div><br></div></blockquote></div><br></div>