question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New rule proposal: Literal Suffixes should be uppercase

See original GitHub issue

New 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:open
  • Created 8 years ago
  • Reactions:2
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
sharwellcommented, Sep 28, 2015

I’m currently a “weak no” on this for the following reasons:

  1. While it’s clear to me that L is preferable to l, it’s not so clear that this makes any difference for other suffixes. In fact, for the suffix m and the e 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.
  2. I’ve never seen anyone use the lowercase suffix for integer literals.

@berkeleybross Have you looked for any instances of this syntax in open source projects?

1reaction
GregReddickcommented, Nov 10, 2015

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found