[llvm-dev] Coding style. VariableNames, not variableNames?

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

[llvm-dev] Coding style. VariableNames, not variableNames?

Chris Lattner via llvm-dev
Hey,

A colleague just pointed out that the style guide says:
Variable names ... should be camel case, and start with an upper case letter

I was under the impression that variables were supposed to be camel case, without a leading upper case, as currently recommended for function names. Is this a somewhat recent change? If so, could someone share a regex / script for updating the previous style to this one?

This implies that the traditional i,j,k loop indices should now be spelled I,J,K. Is is worth making an exception for single character variables where the meaning is implicit from the context?

As an edge case, should function pointers be leading lower case (as they're functions) or leading upper case (as they're variables)?

Cheers,

Jon

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

Re: [llvm-dev] Coding style. VariableNames, not variableNames?

Chris Lattner via llvm-dev
Hi Jon,

On Thu, 25 Apr 2019 at 09:07, Jon Chesterfield via llvm-dev
<[hidden email]> wrote:
> I was under the impression that variables were supposed to be camel case, without a leading upper case, as currently recommended for function names. Is this a somewhat recent change? If so, could someone share a regex / script for updating the previous style to this one?

It's not a recent change, but there has been a recent thread about
switching to variableNames (amongst other things):
https://reviews.llvm.org/D57896,
https://lists.llvm.org/pipermail/llvm-dev/2019-February/130083.html

> This implies that the traditional i,j,k loop indices should now be spelled I,J,K. Is is worth making an exception for single character variables where the meaning is implicit from the context?

I certainly would, and it seems most people agree. "int i " seems to
be about 4x as common as "int I ".

> As an edge case, should function pointers be leading lower case (as they're functions) or leading upper case (as they're variables)?

I believe they're mostly upper-case right now (though pretty rare). I
think named lambda helpers vary more but still favour upper-case.

Cheers.

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

Re: [llvm-dev] Coding style. VariableNames, not variableNames?

Chris Lattner via llvm-dev
Hey Tim,

It's not a recent change, but there has been a recent thread about
switching to variableNames (amongst other things):
https://reviews.llvm.org/D57896,
https://lists.llvm.org/pipermail/llvm-dev/2019-February/130083.html

Thanks for the link. Owing to my poor reading of the coding style, our out of tree back end is lowerCased. Sad times. I'll watch the RFC with interest.

Cheers,

Jon



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