[llvm-dev] RFC: should we spell lambdas like functions?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] RFC: should we spell lambdas like functions?

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

- Use verbs, not nouns.
- Use lowerCamelCase.

Here's a patch that implements the change to the coding standards:

Thoughts?

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] RFC: should we spell lambdas like functions?

Zhizhou Yang via llvm-dev
On Thu, Jul 5, 2018 at 12:57 PM Duncan P. N. Exon Smith <[hidden email]> wrote:
I argue we should spell C++ lambdas (and other function-like variables) like functions, not like variables.

- Use verbs, not nouns.

I think I agree with this.
 
- Use lowerCamelCase.

In lld we use UpperCamelCase, as they are technically not function names but variable names. Using lowerCamelCase for function pointers feels really weird to me, as they are really variables than functions to me.

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] RFC: should we spell lambdas like functions?

Zhizhou Yang via llvm-dev


> On Jul 5, 2018, at 1:09 PM, Rui Ueyama via llvm-dev <[hidden email]> wrote:
>
>> On Thu, Jul 5, 2018 at 12:57 PM Duncan P. N. Exon Smith <[hidden email]> wrote:
>> I argue we should spell C++ lambdas (and other function-like variables) like functions, not like variables.
>>
>> - Use verbs, not nouns.
>
> I think I agree with this.
>  
>> - Use lowerCamelCase.
>
> In lld we use UpperCamelCase, as they are technically not function names but variable names. Using lowerCamelCase for function pointers feels really weird to me, as they are really variables than functions to me.

I also agree that this is weird either way because they are variables when declared and passed around and functions when invoked.

A potential solution would be to adopt the style that large parts of the Clang frontend (informally) uses, and spell variables as lowerCamelCase, too.

-- adrian

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] RFC: should we spell lambdas like functions?

Zhizhou Yang via llvm-dev


On Thu, Jul 5, 2018 at 5:30 PM, Adrian Prantl via llvm-dev <[hidden email]> wrote:


> On Jul 5, 2018, at 1:09 PM, Rui Ueyama via llvm-dev <[hidden email]> wrote:
>
>> On Thu, Jul 5, 2018 at 12:57 PM Duncan P. N. Exon Smith <[hidden email]> wrote:
>> I argue we should spell C++ lambdas (and other function-like variables) like functions, not like variables.
>>
>> - Use verbs, not nouns.
>
> I think I agree with this.

>> - Use lowerCamelCase.
>
> In lld we use UpperCamelCase, as they are technically not function names but variable names. Using lowerCamelCase for function pointers feels really weird to me, as they are really variables than functions to me.

I also agree that this is weird either way because they are variables when declared and passed around and functions when invoked.

How is this different to function pointers in traditional C?
 

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] RFC: should we spell lambdas like functions?

Zhizhou Yang via llvm-dev
In reply to this post by Zhizhou Yang via llvm-dev


On Jul 5, 2018, at 12:57 PM, Duncan P. N. Exon Smith via llvm-dev <[hidden email]> wrote:

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

- Use verbs, not nouns.
- Use lowerCamelCase.

Here's a patch that implements the change to the coding standards:

Makes sense to me, I think that all callable values could be named in the same approach, including function references and std::functions?  Function pointers are not callable (you need to dereference them) so it is arguable that they should be capitalized.  It would be nice to include some rationale of why you’re picking one thing or another in coding standard paragraph.

-Chris


_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] RFC: should we spell lambdas like functions?

Zhizhou Yang via llvm-dev


On Jul 7, 2018, at 8:15 AM, Chris Lattner <[hidden email]> wrote:



On Jul 5, 2018, at 12:57 PM, Duncan P. N. Exon Smith via llvm-dev <[hidden email]> wrote:

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

- Use verbs, not nouns.
- Use lowerCamelCase.

Here's a patch that implements the change to the coding standards:

Makes sense to me, I think that all callable values could be named in the same approach, including function references and std::functions?  Function pointers are not callable (you need to dereference them) so it is arguable that they should be capitalized.  It would be nice to include some rationale of why you’re picking one thing or another in coding standard paragraph.

Err, yeah, of course function pointers are callable.  I meant to say C++ member pointers :)

-Chris


_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] RFC: should we spell lambdas like functions?

Zhizhou Yang via llvm-dev
In reply to this post by Zhizhou Yang via llvm-dev


On Jul. 5, 2018, at 18:12, Bruce Hoult via llvm-dev <[hidden email]> wrote:



On Thu, Jul 5, 2018 at 5:30 PM, Adrian Prantl via llvm-dev <[hidden email]> wrote:


> On Jul 5, 2018, at 1:09 PM, Rui Ueyama via llvm-dev <[hidden email]> wrote:
> 
>> On Thu, Jul 5, 2018 at 12:57 PM Duncan P. N. Exon Smith <[hidden email]> wrote:
>> I argue we should spell C++ lambdas (and other function-like variables) like functions, not like variables.
>> 
>> - Use verbs, not nouns.
> 
> I think I agree with this.
 
>> - Use lowerCamelCase.
> 
> In lld we use UpperCamelCase, as they are technically not function names but variable names. Using lowerCamelCase for function pointers feels really weird to me, as they are really variables than functions to me.

I also agree that this is weird either way because they are variables when declared and passed around and functions when invoked.

How is this different to function pointers in traditional C?
 

It's not different.  The patch proposes to spell C++ lambdas *and other function-like variables* like functions.  Essentially, anything that's callable.

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] RFC: should we spell lambdas like functions?

Zhizhou Yang via llvm-dev

On Tue, Jul 10, 2018 at 4:21 PM Duncan P. N. Exon Smith <[hidden email]> wrote:


On Jul. 5, 2018, at 18:12, Bruce Hoult via llvm-dev <[hidden email]> wrote:



On Thu, Jul 5, 2018 at 5:30 PM, Adrian Prantl via llvm-dev <[hidden email]> wrote:


> On Jul 5, 2018, at 1:09 PM, Rui Ueyama via llvm-dev <[hidden email]> wrote:
> 
>> On Thu, Jul 5, 2018 at 12:57 PM Duncan P. N. Exon Smith <[hidden email]> wrote:
>> I argue we should spell C++ lambdas (and other function-like variables) like functions, not like variables.
>> 
>> - Use verbs, not nouns.
> 
> I think I agree with this.
 
>> - Use lowerCamelCase.
> 
> In lld we use UpperCamelCase, as they are technically not function names but variable names. Using lowerCamelCase for function pointers feels really weird to me, as they are really variables than functions to me.

I also agree that this is weird either way because they are variables when declared and passed around and functions when invoked.

How is this different to function pointers in traditional C?
 

It's not different.  The patch proposes to spell C++ lambdas *and other function-like variables* like functions.  Essentially, anything that's callable.

That seems a bit more awkward/not-clearly-good to me (though I do appreciate that the standard C++ naming convention, for all that it doesn't really differentiate between anything (except macros) by having everything lower_case, does use the same convention between variables and functions so you don't get that disconnect) - ending up with function-named variables that don't behave like functions (get used in assignments, have member functions called on them, compared to nullptr (weak functions notwithstanding), etc).

Seems more like a narrow kind of hungarian notation to me - to designate that this variable can be called. Which doesn't seem important enough to callout with a separate naming convention.

But I'm not too fussed about it if others feel strongly.

- Dave

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] RFC: should we spell lambdas like functions?

Zhizhou Yang via llvm-dev
I wrote that I prefer CamelCase over camelCase for callable objects, but I don't have a strong opinion. If the majority prefers camelCase, I'm happy to update the existing lld's code to conform to the new coding style.

On Tue, Jul 10, 2018 at 4:25 PM David Blaikie via llvm-dev <[hidden email]> wrote:

On Tue, Jul 10, 2018 at 4:21 PM Duncan P. N. Exon Smith <[hidden email]> wrote:


On Jul. 5, 2018, at 18:12, Bruce Hoult via llvm-dev <[hidden email]> wrote:



On Thu, Jul 5, 2018 at 5:30 PM, Adrian Prantl via llvm-dev <[hidden email]> wrote:


> On Jul 5, 2018, at 1:09 PM, Rui Ueyama via llvm-dev <[hidden email]> wrote:
> 
>> On Thu, Jul 5, 2018 at 12:57 PM Duncan P. N. Exon Smith <[hidden email]> wrote:
>> I argue we should spell C++ lambdas (and other function-like variables) like functions, not like variables.
>> 
>> - Use verbs, not nouns.
> 
> I think I agree with this.
 
>> - Use lowerCamelCase.
> 
> In lld we use UpperCamelCase, as they are technically not function names but variable names. Using lowerCamelCase for function pointers feels really weird to me, as they are really variables than functions to me.

I also agree that this is weird either way because they are variables when declared and passed around and functions when invoked.

How is this different to function pointers in traditional C?
 

It's not different.  The patch proposes to spell C++ lambdas *and other function-like variables* like functions.  Essentially, anything that's callable.

That seems a bit more awkward/not-clearly-good to me (though I do appreciate that the standard C++ naming convention, for all that it doesn't really differentiate between anything (except macros) by having everything lower_case, does use the same convention between variables and functions so you don't get that disconnect) - ending up with function-named variables that don't behave like functions (get used in assignments, have member functions called on them, compared to nullptr (weak functions notwithstanding), etc).

Seems more like a narrow kind of hungarian notation to me - to designate that this variable can be called. Which doesn't seem important enough to callout with a separate naming convention.

But I'm not too fussed about it if others feel strongly.

- Dave
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] RFC: should we spell lambdas like functions?

Zhizhou Yang via llvm-dev
In reply to this post by Zhizhou Yang via llvm-dev
On Thu, Jul 5, 2018 at 12:57 PM Duncan P. N. Exon Smith via llvm-dev <[hidden email]> wrote:
I argue we should spell C++ lambdas (and other function-like variables) like functions, not like variables.

- Use verbs, not nouns.

Totally agree.
 
- Use lowerCamelCase.

Really disagree.

I don't like having two different case conventions for variables. They're all variables, and I think they should be named using the same convention.
 

Here's a patch that implements the change to the coding standards:

Thoughts?
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] RFC: should we spell lambdas like functions?

Zhizhou Yang via llvm-dev
On 7/11/2018 5:38 AM, Chandler Carruth via llvm-dev wrote:
>
> I don't like having two different case conventions for variables.
> They're all variables, and I think they should be named using the same
> convention.

Really agree.

What about situations where a function is a parameter:
   template <typename Func> void fred(int Arg, Func Do) {...}
If we use lowercase names for the function parameters it is going to
look awful.

-Krzysztof

--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] RFC: should we spell lambdas like functions?

Zhizhou Yang via llvm-dev
In reply to this post by Zhizhou Yang via llvm-dev
- Use lowerCamelCase.

FWIW I would prefer to name them like variables too. Since being callable is their raison d'etre I'm unlikely to forget to use them that way. On the other hand, naming them like variables is a subtle but helpful reminder that they can be assigned to, moved from, may be default constructed (and so in a not-callable state), etc.

Cheers,
Lang.

On Wed, Jul 11, 2018 at 3:39 AM Chandler Carruth via llvm-dev <[hidden email]> wrote:
On Thu, Jul 5, 2018 at 12:57 PM Duncan P. N. Exon Smith via llvm-dev <[hidden email]> wrote:
I argue we should spell C++ lambdas (and other function-like variables) like functions, not like variables.

- Use verbs, not nouns.

Totally agree.
 
- Use lowerCamelCase.

Really disagree.

I don't like having two different case conventions for variables. They're all variables, and I think they should be named using the same convention.
 

Here's a patch that implements the change to the coding standards:

Thoughts?
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev