I'm against it since we can do it better in library with same efficiency and better UFCS syntax: see
to test it, nothing to install, just type: rdmd --main -unittest dtools/all.d
here's the unittest:
----
version(unittest){
import std.stdio;
int foo(int x){
return x;
}
}
unittest{
double c;
// auto b1=cast(int)c.foo;//means cast(int)(c.foo), so would be CT error
auto b2=(cast(int)c).foo;//verbose syntax: 2 nested parenthesis
auto b3=c.Cast!int.foo;//simpler syntax
int a=1;
auto b=(a+a).Cast!double;
static assert(is(typeof(b)==double));
static assert(is(typeof(a.Cast!Immutable)==immutable(int)));
static assert(is(typeof(a.Cast!Const)==const(int)));
static assert(is(typeof(0U.Cast!Signed)==int));
static assert(is(typeof(a.Cast!Unsigned)==uint));
static assert(is(typeof(a.Cast!Const)==const(int)));
static assert(is(typeof((a+a).Cast!Unsigned)==uint));
}
----
On Fri, Jun 7, 2013 at 5:43 PM, Mrzlga
<bulletproofchest@gmail.com> wrote:
"doing nothing but converting unsigned->signed" is a dubious statement.
They are still screwing with the range, they are not just "doing nothing but converting unsigned->signed".
And 'int' says something about the outcome.
So I am really asking for:
cast(signed int) x; // make them poor programmers write this, lol
That's not what I actually want, but at least it shows: We're making a signed conversion, AND we're screwing with the range to make it into an int.
for further thought.