"R" suffix for reals
James Miller
james at aatch.net
Sun May 6 16:17:54 PDT 2012
On Sunday, 6 May 2012 at 22:49:13 UTC, bearophile wrote:
> "R" suffix for reals
>
> This is small enhancement suggestion :-) (Issue 8049).
>
> 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));
> }
>
> D has "auto" for local inferencing, so this suffix is able to
> cause some problems.
>
> So what do you think about introducing a more specific and less
> bug-prone suffix like "R" (eventually using "L" to denote
> longs only):
>
> void main() {
> auto x = 1R;
> static assert(is(typeof(x) == real));
> }
>
> Bye,
> bearophile
I agree with this proposal, phasing out 'L' for reals seems like
a good idea, I didn't even know that it was possible until now,
so I imagine it can't be stepping on many people's toes.
--
James Miller
More information about the Digitalmars-d
mailing list