On Saturday, 7 February 2015 at 02:12:08 UTC, Jakob Ovrum wrote:
Byte echo(Byte b)
{
return b;
}
b = echo('a');
b = echo(cast(const char)'a');
b = echo(cast(immutable char)'a');
b = echo(cast(byte)1);
b = echo(cast(const byte)1);
b = echo(cast(immutable byte)1);
b = echo(cast(ubyte)1);
b = echo(cast(const ubyte)1);
b = echo(cast(immutable ubyte)1);
Byte[] barr;
barr = "teststring";
barr = [0,1,2,3];
}
These are not possible as D does not support implicit
construction.
It's a bit odd that D supports implicit conversions from
user-defined types to built-in types but not the reverse. What's
the reason for this? Is it done on purpose or is this just a
hole that might be filled in later?