"R" suffix for reals
Mehrdad
wfunction at hotmail.com
Sun May 6 18:15:19 PDT 2012
That's why you shouldn't http://www.quickmeme.com/meme/3p5mcu/
On Monday, 7 May 2012 at 01:02:29 UTC, bearophile wrote:
> Jonathan M Davis:
>
>> And what is so onerous about having to do 1.0L instead of 1R?
>
> It's not onerous, the purpose of "R" is not to save typing ".0".
>
>
>> (it would have to be either double or real, and
>> apparently it's real).
>
> 1.0L is always a real in D.
>
>
>> We _could_ add R, but I don't really see what it buys us.
>
> Octal literals are deprecated in D because programmers
> sometimes forget about them, or make mistakes adding a leading
> zero, thinking it does nothing as in math, and defining a
> number different from the desired one.
>
> If you write "auto x = 1L;" thinking about defining a real, as
> you define a float with "auto x = 1F;" you are introducing a
> small bug.
>
> Or maybe you initially have written:
> auto r = 1.1L;
> And later you want to change the number to 1.0 and you fix it
> like this:
> auto r = 1L;
> Now you have a little bug.
>
> The "R" is more symmetric with "f", it works as "f" for real.
> This makes learning D a bit simpler.
>
> Very often it's better to have literals as much specific as
> possible, otherwise you get situations like the following one,
> what's the problem here (Issue 4703)?
>
> import std.stdio: writeln;
> void main() {
> int[] associative_array = [1:2, 3:4, 5:6];
> writeln(associative_array);
> }
>
> Bye,
> bearophile
More information about the Digitalmars-d
mailing list