Reflection: Get name of class/type

BlitzMax Forums/BlitzMax Beginners Area/Reflection: Get name of class/type

GuntiNDDS(Posted 2010) [#1]
I thought this should work:

Print TTypeId.ForObject(Self).Name()

But it generates an "Unable to convert from 'Type' to 'Object'" error. Even tho Self should point to the object rather then the type according to the manual.

Any Ideas ?

Thanks.


Dreamora(Posted 2010) [#2]
Self is no object reference


GuntiNDDS(Posted 2010) [#3]
Well, this is the description of "Self" in the manual:


Reference to this Method's Object instance




plash(Posted 2010) [#4]
Are you trying to call that from a Function?

SuperStrict

Framework brl.blitz
Import brl.standardio
Import brl.reflection

Local blah:TBlah = New TBlah
blah.Test()

Type TBlah
	
	Method Test()
		Print(TTypeId.ForObject(Self).Name())
	End Method
	
End Type


I find it interesting that Max determines 'Self' to actually be a type in type functions (as it doesn't actually have any use).


GuntiNDDS(Posted 2010) [#5]
Wow you are right. I was calling it from a function. /facepalm ^^

Thanks !


Otus(Posted 2010) [#6]
Interesting, though mostly useless:
SuperStrict
Framework BRL.StandardIO

Type T
	Function f:T()
		Return New Self
	End Function
End Type

If T.f() Print "Works!"



plash(Posted 2010) [#7]
Yeah, I assumed that was going to work.