Sean Silva
2014-Apr-15 03:14 UTC
[LLVMdev] local lambdas: request for coding standard clarification/judgement call
Do local lambdas get named like variables or like functions? E.g. void foo() { auto helper = [](...){...}; // or auto Helper = [](...){...}; } My gut is that it should be lowercase (named like a function) since I got a weird feeling in my stomach seeing an upper-case name being called like a function in new code. -- Sean Silva -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140414/b2b7a0de/attachment.html>
Duncan Exon Smith
2014-Apr-15 03:34 UTC
[LLVMdev] local lambdas: request for coding standard clarification/judgement call
> On Apr 14, 2014, at 20:14, Sean Silva <chisophugis at gmail.com> wrote: > > Do local lambdas get named like variables or like functions? > > E.g. > > void foo() { > auto helper = [](...){...};It should be "help" here (verb), not "helper" (noun), but this is the direction I like. It's a local function!> // or > auto Helper = [](...){...}; > } > > My gut is that it should be lowercase (named like a function) since I got a weird feeling in my stomach seeing an upper-case name being called like a function in new code. > > -- Sean Silva > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
David Majnemer
2014-Apr-15 16:00 UTC
[LLVMdev] local lambdas: request for coding standard clarification/judgement call
Because lambdas can be stateful, they are not simple functions. I see lambdas as a shorthand for writing out a functor. I would write "Helper" because it is an object of the closure type while the function itself is "operator()". On Mon Apr 14 2014 at 8:37:14 PM, Duncan Exon Smith <dexonsmith at apple.com> wrote:> > > On Apr 14, 2014, at 20:14, Sean Silva <chisophugis at gmail.com> wrote: > > > > Do local lambdas get named like variables or like functions? > > > > E.g. > > > > void foo() { > > auto helper = [](...){...}; > > It should be "help" here (verb), not "helper" (noun), but this is the > direction I like. It's a local function! > > > // or > > auto Helper = [](...){...}; > > } > > > > My gut is that it should be lowercase (named like a function) since I > got a weird feeling in my stomach seeing an upper-case name being called > like a function in new code. > > > > -- Sean Silva > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140415/a39e5472/attachment.html>
Sean Silva
2014-Apr-15 21:40 UTC
[LLVMdev] local lambdas: request for coding standard clarification/judgement call
On Mon, Apr 14, 2014 at 11:34 PM, Duncan Exon Smith <dexonsmith at apple.com>wrote:> > > On Apr 14, 2014, at 20:14, Sean Silva <chisophugis at gmail.com> wrote: > > > > Do local lambdas get named like variables or like functions? > > > > E.g. > > > > void foo() { > > auto helper = [](...){...}; > > It should be "help" here (verb), not "helper" (noun), but this is the > direction I like. It's a local function! >I didn't mean anything by the name here besides the case; I should have just written "bar". I think David's point about the lambda being the object of closure type while the function itself is "operator()" could be used to argue for naming it as a noun, although I expect that most local lambdas will more naturally be verbs (the original case which got me to write this post was a local lambda called "eat"). -- Sean Silva> > > // or > > auto Helper = [](...){...}; > > } > > > > My gut is that it should be lowercase (named like a function) since I > got a weird feeling in my stomach seeing an upper-case name being called > like a function in new code. > > > > -- Sean Silva > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140415/c2968769/attachment.html>