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". 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.
Perhaps it means nothing, but I'll comment anyways.
To me if I were to add suffixes, it would be the first letter of
what made sense, goes with a default type we know. With the
exception of using a-f being hex codes already known.
So...
b - binary
s - short - likely unneeded
l - long
f - float
r - real
o - octal
h - hexidecimal (or prefix 0x since it's so common and stands
out)
prepend u to any to make unsigned, so ul is unsigned long, ie
10ul. (makes binary safe as ub, but that's kinda ugly)
? - byte
? - int/decimal
d - double (df for double float?)