New rule proposal: Literal Suffixes should be uppercase
See original GitHub issueNew rule proposal: Literal Suffixes should be uppercase
Category: Readability Rule: Literal suffixes should be uppercase Rationale: Improves readability of code, following recommendation from C# specification
Bad:
long foo = 50l;
decimal bar = 50.4m;
Good:
long foo = 50L;
decimal bar = 50.4M;
See https://msdn.microsoft.com/en-us/library/aa664674(v=vs.71).aspx for the specification for integer literals, in particular the following paragraph:
As a matter of style, it is suggested that “L” be used instead of “l” when writing literals of type long, since it is easy to confuse the letter “l” with the digit “1”.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:2
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Literal suffix "L" for long integers shall be upper case
Using upper case literal suffixes removes the potential ambiguity between "1" (digit 1) and "l" (letter el) for declaring literals. Noncompliant code example....
Read more >V2517. MISRA. Literal suffixes should not contain ...
MISRA. Literal suffixes should not contain lowercase characters. This diagnostic rule is based on the software development guidelines developed by MISRA (Motor ...
Read more >readability-uppercase-literal-suffix - clang-tidy
Detects when the integral literal or floating point (decimal or hexadecimal) literal has a non-uppercase suffix and provides a fix-it hint with the...
Read more >C# 11 Preview Updates - Raw string literals, UTF-8 and ...
There are ongoing discussions about details such as whether a type suffix is required and what natural type that would imply. If you...
Read more >PEP 8 – Style Guide for Python Code
Use 4 spaces per indentation level. Continuation lines should align wrapped elements either vertically using Python's implicit line joining inside parentheses, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m currently a “weak no” on this for the following reasons:
L
is preferable tol
, it’s not so clear that this makes any difference for other suffixes. In fact, for the suffixm
and thee
which appears in floating point values, I almost feel like the lowercase version is more easily distinguished and possibly even more common in existing code.@berkeleybross Have you looked for any instances of this syntax in open source projects?
I think there should be a consistent rule on the literal suffixes. I really don’t care what it is, I can live with whatever is decided, but there should be one. It can’t violate CS0078. I hate looking through my code and finding that I do something one way in one place and a different way in another place.