On 15.06.2012 16:11, Timon Gehr wrote:
Why not allow equality operators to operate on types?

is(==) expressions tend to create bracket noise and treat the two
arguments non-uniformly.

This would suggest a little parser update, so that eg. 'int', '(int*)'
and 'int[]' are accepted as valid expressions. (this also potentially
improves compiler error messages.)

void foo(T)(T arg){
static if(T==int){
...
}else{
...
}


Now one day some n00b uses run-time if-chains to create type-switch (that doesn't work because it would CT-defined):
...
if( typeof(a) == Foo)
...
else if(typeof(a) == Bar)
...

Though "code is unreachable" warning might help with it.
static if(T!=double) ...
}

As far as I can see, this would be fully backwards-compatible.
(modulo compile-time introspection.)


--
Dmitry Olshansky

Reply via email to