View Issue Details

IDProjectCategoryView StatusLast Update
0037783FPCCompilerpublic2020-09-24 00:21
ReporterZamrony P. Juhara Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityN/A
Status resolvedResolutionwon't fix 
Summary0037783: Feature request: ability to use underscore as separator in number literal
DescriptionAbility to use underscore as number literal separator for improve code readability.
For example

const
      ONE_MILLION = 1_000_000;
      FLAG = %1111_1111_1111_1111;
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Activities

Michael Van Canneyt

2020-09-21 08:59

administrator   ~0125696

No, really not. If only for Delphi compatibility.
The various $ % & etc. are bad enough, we don't need even more junk characters in the numbers

Heiko

2020-09-21 09:55

reporter   ~0125698

See also https://www.informit.com/articles/article.aspx?p=2209021

With the pros and cons in 'Quotation Mark as Digit Separator'

nanobit

2020-09-21 10:47

reporter   ~0125701

Last edited: 2020-09-21 10:52

View 2 revisions

More language references could be useful:

Python:
https://www.python.org/dev/peps/pep-0515/
https://docs.python.org/3/reference/lexical_analysis.html#integer-literals

C#:
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-7.0/digit-separators
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types

runewalsh

2020-09-24 00:21

reporter   ~0125801

I personally don't see much of a point in underscores, even in languages that have them.
const
  ONE_MILLION = 1000 * 1000;
  FLAG = %1111 shl 12 or %1111 shl 8 or %1111 shl 4 or %1111;

Issue History

Date Modified Username Field Change
2020-09-21 01:17 Zamrony P. Juhara New Issue
2020-09-21 08:59 Michael Van Canneyt Assigned To => Michael Van Canneyt
2020-09-21 08:59 Michael Van Canneyt Status new => resolved
2020-09-21 08:59 Michael Van Canneyt Resolution open => won't fix
2020-09-21 08:59 Michael Van Canneyt FPCTarget => -
2020-09-21 08:59 Michael Van Canneyt Note Added: 0125696
2020-09-21 09:55 Heiko Note Added: 0125698
2020-09-21 10:47 nanobit Note Added: 0125701
2020-09-21 10:52 nanobit Note Edited: 0125701 View Revisions
2020-09-24 00:21 runewalsh Note Added: 0125801