www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3837] New: Safer number literals

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3837

           Summary: Safer number literals
           Product: D
           Version: 2.040
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2010-02-18 13:25:35 PST ---
Octal numbers are not common, but sometimes less experienced programmers can
add leading zeros to align numbers or for other purposes, and this can cause
bugs:

int x = 010;
This assigns x to value 8. 

To avoid that bug D can turn leading zeros in syntax errors (for safety with
code ported from C to D), and a safer syntax can be introduced for octal
literals, for example like in Python3 (or some other syntax can be invented):

0o10
0O10


Optionally D can also turn FP literals like the following into syntax errors:
.5
3.
To require something like:
0.5
3.0
But this is less important than the octal syntax.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 18 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3837


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug yahoo.com.au
         Resolution|                            |DUPLICATE


--- Comment #1 from Don <clugdbug yahoo.com.au> 2010-03-12 08:25:16 PST ---
*** This issue has been marked as a duplicate of issue 2656 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 12 2010