[PATCH] D83431: [Docs] CodingStandards: for_each is discouraged

Nick Desaulniers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 8 15:27:07 PDT 2020


nickdesaulniers added a comment.

> As per lengthy/heated disscussion in D83351 <https://reviews.llvm.org/D83351>,

Probably could drop those adjectives. =P  Also, s/disscussion/discussion/.

> using for_each is potentially confusing,

I guess @dblaikie did use the term confusing <https://reviews.llvm.org/D83351#2139769>, but it might be useful to better reflect his point about confusion in regards to inconsistent style in the commit message.  It certainly begs the question otherwise.



================
Comment at: llvm/docs/CodingStandards.rst:1305
 
+Usage of ``std::for_each()``/``llvm::for_each()`` functions is discouraged.
+
----------------
lebedev.ri wrote:
> hubert.reinterpretcast wrote:
> > Even if what's available in the context of the code is a pair of iterators and a callable (and using a range-based for loop would involve extra boilerplate)?
> That is my understanding, yes.
it might be useful to provide more information here.

Use of X is discouraged because ...

IIUC @dblaikie 's points in https://reviews.llvm.org/D83351#2139727 and https://reviews.llvm.org/D83351#2139861 were that:
1. more concise error messages.
2. more concise unless an existing function/method/lambda already exists.

I love functional programming styles, but if an inline lambda definition isn't shorter than a range-for, I agree with @dblaikie and feel a lambda is overkill.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83431/new/

https://reviews.llvm.org/D83431





More information about the llvm-commits mailing list