|
|
DescriptionClarify uncapturing lambda functions with Bind styleguide.
Update style guide to explicitly condone lambdas that
do not capture with Bind, E.G.:
base::Bind([](int j){}, i);
Committed: https://crrev.com/ea2f9d51d4d57d7a26a28e375ff7c1d67f58fab5
Cr-Commit-Position: refs/heads/master@{#422217}
Patch Set 1 #
Total comments: 4
Patch Set 2 : danakj addressed #Messages
Total messages: 14 (7 generated)
Description was changed from ========== Clarify uncapturing lambda functions with Bind styleguide. ========== to ========== Clarify uncapturing lambda functions with Bind styleguide. Update style guide to explicitly condone lambdas that do not capture with Bind, E.G.: base::Bind([](int j){}, i); ==========
scheib@chromium.org changed reviewers: + dcheng@chromium.org
danakj@chromium.org changed reviewers: + danakj@chromium.org
LGTM https://codereview.chromium.org/2382103003/diff/1/styleguide/c++/c++11.html File styleguide/c++/c++11.html (right): https://codereview.chromium.org/2382103003/diff/1/styleguide/c++/c++11.html#n... styleguide/c++/c++11.html:198: <td>Do not bind or store capturing lambdas outside the lifetime of the stack frame they are defined in. Captureless lambdas are OK, E.G. <code>base::Bind([](int j){}, i);</code> with <code>base::Callback</code>, because they offer protection against a large class of object lifetime mistakes. Don't use default captures (<code>[=]</code>, <code>[&]</code> – <a href="https://google.github.io/styleguide/cppguide.html#Lambda_expressions">Google Style Guide</a>). Lambdas are typically useful as a parameter to methods or functions that will use them immediately, such as those in <code><algorithm></code>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/D9UnnxBnciQ">Discussion thread</a>, <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/QxjsPELDYdQ">uncapturing thread</a>. nit: Can you reword this a little bit. Like: Captureless lambdas can be used with <code>base::Callback</code>, such as <code>base::Bind([].......)</code>.
non-owner LGTM with danakj's comments addressed https://codereview.chromium.org/2382103003/diff/1/styleguide/c++/c++11.html File styleguide/c++/c++11.html (right): https://codereview.chromium.org/2382103003/diff/1/styleguide/c++/c++11.html#n... styleguide/c++/c++11.html:198: <td>Do not bind or store capturing lambdas outside the lifetime of the stack frame they are defined in. Captureless lambdas are OK, E.G. <code>base::Bind([](int j){}, i);</code> with <code>base::Callback</code>, because they offer protection against a large class of object lifetime mistakes. Don't use default captures (<code>[=]</code>, <code>[&]</code> – <a href="https://google.github.io/styleguide/cppguide.html#Lambda_expressions">Google Style Guide</a>). Lambdas are typically useful as a parameter to methods or functions that will use them immediately, such as those in <code><algorithm></code>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/D9UnnxBnciQ">Discussion thread</a>, <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/QxjsPELDYdQ">uncapturing thread</a>. Super duper tiny extra small nit: e.g. is usually written in all lowercase
The CQ bit was checked by scheib@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from danakj@chromium.org, dcheng@chromium.org Link to the patchset: https://codereview.chromium.org/2382103003/#ps20001 (title: "danakj addressed")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
https://codereview.chromium.org/2382103003/diff/1/styleguide/c++/c++11.html File styleguide/c++/c++11.html (right): https://codereview.chromium.org/2382103003/diff/1/styleguide/c++/c++11.html#n... styleguide/c++/c++11.html:198: <td>Do not bind or store capturing lambdas outside the lifetime of the stack frame they are defined in. Captureless lambdas are OK, E.G. <code>base::Bind([](int j){}, i);</code> with <code>base::Callback</code>, because they offer protection against a large class of object lifetime mistakes. Don't use default captures (<code>[=]</code>, <code>[&]</code> – <a href="https://google.github.io/styleguide/cppguide.html#Lambda_expressions">Google Style Guide</a>). Lambdas are typically useful as a parameter to methods or functions that will use them immediately, such as those in <code><algorithm></code>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/D9UnnxBnciQ">Discussion thread</a>, <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/QxjsPELDYdQ">uncapturing thread</a>. On 2016/09/30 18:38:18, danakj wrote: > nit: Can you reword this a little bit. Like: Captureless lambdas can be used > with <code>base::Callback</code>, such as <code>base::Bind([].......)</code>. Done. https://codereview.chromium.org/2382103003/diff/1/styleguide/c++/c++11.html#n... styleguide/c++/c++11.html:198: <td>Do not bind or store capturing lambdas outside the lifetime of the stack frame they are defined in. Captureless lambdas are OK, E.G. <code>base::Bind([](int j){}, i);</code> with <code>base::Callback</code>, because they offer protection against a large class of object lifetime mistakes. Don't use default captures (<code>[=]</code>, <code>[&]</code> – <a href="https://google.github.io/styleguide/cppguide.html#Lambda_expressions">Google Style Guide</a>). Lambdas are typically useful as a parameter to methods or functions that will use them immediately, such as those in <code><algorithm></code>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/D9UnnxBnciQ">Discussion thread</a>, <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/QxjsPELDYdQ">uncapturing thread</a>. On 2016/09/30 18:41:27, dcheng wrote: > Super duper tiny extra small nit: e.g. is usually written in all lowercase Done.
The CQ bit was unchecked by commit-bot@chromium.org
Failed to apply the patch. On branch working_branch Your branch is up-to-date with 'origin/refs/pending/heads/master'. nothing to commit, working tree clean
Message was sent while issue was closed.
Description was changed from ========== Clarify uncapturing lambda functions with Bind styleguide. Update style guide to explicitly condone lambdas that do not capture with Bind, E.G.: base::Bind([](int j){}, i); ========== to ========== Clarify uncapturing lambda functions with Bind styleguide. Update style guide to explicitly condone lambdas that do not capture with Bind, E.G.: base::Bind([](int j){}, i); Committed: https://crrev.com/ea2f9d51d4d57d7a26a28e375ff7c1d67f58fab5 Cr-Commit-Position: refs/heads/master@{#422217} ==========
Message was sent while issue was closed.
Patchset 2 (id:??) landed as https://crrev.com/ea2f9d51d4d57d7a26a28e375ff7c1d67f58fab5 Cr-Commit-Position: refs/heads/master@{#422217} |