My impression was that lambdas should be formatted as variables, and all code I’ve written and reviewed in recent years has followed that convention. I do recall seeing a discussion, but I don’t recall when and I certainly don’t recall the consensus being to use function-casing style (so I’d write IsCommutative as an example).
My logic for casing is that a lambda is more-or-less the same as a class with an operator() method. Imagine the following snippet:
class CommutativeFn {
bool operator()(BinaryOperatorKind Op) { return true; }
};
bool functorClass(...) {
CommutativeFn IsCommutative; // what should this variable's casing be?
return IsCommutative(...);
}
bool lambdaFunction(...) {
const auto isCommutative = [](BinaryOperatorKind Op) { // what should this casing be?
return true;
};
return isCommutative(...);
}
bool functionRef(function_ref<bool(BinaryOperatorKind)> IsCommutative, ...) { // what should this casing be?
return IsCommutative(...);
}
bool isCommutativeFunc(BinaryOperatorKind Op) { return true; }
We have four different situations. I would argue that only the fourth of these (the pure function case) is a function, as opposed to a function object. If you were to argue that the first case should actually also use lower-case, then I would counter with a question: at what point does a class with an operator() stop using that style? How much state/other behaviours/… does it need?
Aside: this is a perfect demonstration as to why it doesn’t make sense to use different casing styles for functions and variables, because they are largely interchangeable in the general sense.