Thread overview
rtti?
Jul 03, 2002
Dario
Jul 04, 2002
Burton Radons
Jul 04, 2002
Dario
Jul 04, 2002
Burton Radons
Jul 04, 2002
Dario
July 03, 2002
(This surely has been already told. I remember I have read about it somewhere, but I don't remember where... I apologize.)

What's the D sintax for RTTI? I tried
if(instance.typeinfo === Class.typeinfo) {/*...*/}
but this doesn't work. I tried
if(instance.classinfo === Class.classinfo) {/*...*/}
but this generates an internal error.

How should I write the D equivalent of the following C++ code?

#include <typeinfo>
class Class {} instance;
if(typeid(instance) == typeid(Class)) {/*...*/}

Thanks in advance for helping me! Dario


July 04, 2002
Dario wrote:
> (This surely has been already told. I remember I have read about it
> somewhere, but I don't remember where... I apologize.)

We discussed it a few weeks ago, but your problem is new.

> What's the D sintax for RTTI? I tried
> if(instance.typeinfo === Class.typeinfo) {/*...*/}
> but this doesn't work. I tried
>
> if(instance.classinfo === Class.classinfo) {/*...*/}
> but this generates an internal error.

This is correct and should work.  Could you boil it down to the smallest amount of code that can cause the internal error and then post that?

July 04, 2002
> > (This surely has been already told. I remember I have read about it somewhere, but I don't remember where... I apologize.)

> We discussed it a few weeks ago, but your problem is new.

> > What's the D sintax for RTTI? I tried
> > if(instance.typeinfo === Class.typeinfo) {/*...*/}
> > but this doesn't work. I tried
> > if(instance.classinfo === Class.classinfo) {/*...*/}
> > but this generates an internal error.

> This is correct and should work.  Could you boil it down to the smallest amount of code that can cause the internal error and then post that?

This compiles good but emits a runtime error:
Error: Object 00690D70



July 04, 2002
Dario wrote:

>>>(This surely has been already told. I remember I have read about it
>>>somewhere, but I don't remember where... I apologize.)
>>>
> 
>>We discussed it a few weeks ago, but your problem is new.
>>
> 
>>>What's the D sintax for RTTI? I tried
>>>if(instance.typeinfo === Class.typeinfo) {/*...*/}
>>>but this doesn't work. I tried
>>>if(instance.classinfo === Class.classinfo) {/*...*/}
>>>but this generates an internal error.
> 
>>This is correct and should work.  Could you boil it down to the smallest
>>amount of code that can cause the internal error and then post that?
> 
> This compiles good but emits a runtime error:
> Error: Object 00690D70

All references are initialised to null, so you're dereferencing a null pointer there.  Putting a "a = new AAA;" before that line should make it work, although you may need to add a constructor.

July 04, 2002
ARGH! I'm so stupid that I forgot that! Thank you Burton! =] Dario