Bug 8049 – Less bug-prone "R" suffix for real number literals
Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-05-05T17:53:00Z
Last change time
2012-06-11T05:21:37Z
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2012-05-05T17:53:44Z
The "f" suffix turns a number literal without "." into a float, while "L" requires a "." in the number literal, otherwise you have defined a literal of type long:
void main() {
auto x1 = 1f;
static assert(is(typeof(x1) == float));
auto x2 = 1L;
static assert(is(typeof(x2) == long));
auto x3 = 1.0L;
static assert(is(typeof(x3) == real));
}
So I suggest to introduce _a less bug-prone_ and more specific suffix like "R" (and maybe deprecate the usage of "L" to define real numbers, so L only defines long integers):
void main() {
auto x = 1R;
static assert(is(typeof(x) == real));
}
Comment #1 by bearophile_hugs — 2012-06-11T05:21:37Z