is expression: library reference

Jonathan M Davis jmdavisProg at gmx.com
Thu Mar 24 10:03:35 PDT 2011


> The library refernce has the following text concerning the is expression:
> 
> 5. is ( Type Identifier : TypeSpecialization )
> 
> The condition is satisfied if Type is the same as TypeSpecialization, or if
> Type is a class and TypeSpecialization is a base class or base interface of
> it. The Identifier is declared to be either an alias of the
> TypeSpecialization or, if TypeSpecialization is dependent on Identifier,
> the deduced type.
> 
> However, the following code fragment will print "short is int" and "short"
> which seems to contradict the above description.
> 
>   static if(is(short T: int)){
>     writeln("short is int");
>     writeln(typeid(T));
>   }else{
>     writeln("short is not int");
>   }
> 
> The observed behaviour is such that short T: int means that short can be
> implicitely converted to int and T is defined to mean "short" rather than
> "int". Thus T is not defined to mean TypeSpecialization but Type. This
> discrepancy should be corrected.

Create a bug report for it: http://d.puremagic.com/issues/

- Jonathan M Davis


More information about the Digitalmars-d mailing list