On Friday, 11 August 2017 at 04:17:32 UTC, ketmar wrote:
Mr. Pib wrote:
string Q(alias T, alias D)()
{
pragma(msg, T);
pragma(msg, D);
enum x = T~" = "~D~";";
pragma(msg, x);
}
mixin(Q!(`x`, 100)());
outputs, at compile time,
x
100
x = d;
there is no lowercase d. I did initially define Q as
string Q(alias T, D)(D d)
and one might think it is remnants left over from I cleaned
the project so it shouldn't be happening. Seems like a bug.
(I realized that I'd probably only ever pass compile time
values)
Of course, using D.stringof gives the value.
The problem is the case of D.
nope. the problem is the *value* of D. `char(100)` == 'd'.
string s = "<"~100~">";
yes, this works. weither this bug or not is questionable, but
this is how D works regerding to implicit type conversions:
small ints (in the range of [0..char.max]) will be implicitly
converted to `char` if necessary.
Wow, that is pretty screwed up! I thought D was against implicit
conversions that might cause problems? I'm passing an int and I
should be able to append an int without having to worry about the
value of the int. Instead D chose to do something very strange,
awkward, and error prone.