is questions

Lucas Goss lgoss007 at gmail.com
Thu Mar 16 12:31:44 PST 2006


pragma wrote:
> Obi-Wan: This is not the idiom you're looking for.  :)

Hahaha...

> D uses the cast() operator to accomplish runtime type checking.  The 'is'
> operator is something else entirely (value/reference equality).

Doh... well thanks! Don't know how I missed that, I was even looking at 
cast too. I must be getting my languages mixed up. In addition, maybe 
the documentation is also confusing. I looked at "is" and it says:

IsExpressions are evaluated at compile time and are used for checking 
for valid types, comparing types for equivalence, determining if one 
type can be implicitly converted to another, and deducing the subtypes 
of a type.

I guess I always think of a class as a custom type. Is that not the 
correct way to think of it? Of course I still prefer this syntax:

if(x is int)

instead of:

if( is(x : int) )



More information about the Digitalmars-d mailing list