Page MenuHomePhabricator

Docs: Spell C++ lambdas like functions, not variables
AbandonedPublic

Authored by dexonsmith on Jul 5 2018, 12:54 PM.

Details

Reviewers
lattner
Summary

I argue we should spell C++ lambdas (and other function-like variables) like functions, not like variables.

  • Use verbs, not nouns.
  • Use lowerCamelCase.

Thoughts?

Diff Detail

Event Timeline

dexonsmith created this revision.Jul 5 2018, 12:54 PM

I've started an RFC on llvm-dev to discuss whether we should make this change:
http://lists.llvm.org/pipermail/llvm-dev/2018-July/124466.html

lattner accepted this revision.Jul 7 2018, 8:12 AM
lattner added a subscriber: lattner.

Patch LGTM, I'd suggest including an example like `auto updateResult = [&](){...`

This revision is now accepted and ready to land.Jul 7 2018, 8:12 AM

Only lambdas, and not other functors (like std::function, etc)?

So we could end up with code like:

MyFunctor = myLambda;

Though I suppose that's OK - and it's only in the local scope of a function
& not like any interesting object-like operations (such as assignment) can
be done with the lambda as the subject anyway, so it does look a lot like a
function... (except you can't assign it to a function pointer - but at
least the lambda should be nearby in the code so that's not too confusing)

Only lambdas, and not other functors (like std::function, etc)?

So we could end up with code like:

MyFunctor = myLambda;

Though I suppose that's OK - and it's only in the local scope of a function
& not like any interesting object-like operations (such as assignment) can
be done with the lambda as the subject anyway, so it does look a lot like a
function... (except you can't assign it to a function pointer - but at
least the lambda should be nearby in the code so that's not too confusing)

I was just about to commit this (with an example), then I saw your comment which I had missed. The idea would actually be:

myFunctor = myLambda;

Essentially, objects primarily used as callable things would be spelled like functions.

Would you rather carve out lambdas specifically?

dexonsmith abandoned this revision.Aug 25 2019, 8:25 AM

Abandoning this in light of the recent discussions.

Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2019, 8:25 AM
Herald added a subscriber: ributzka. · View Herald Transcript