Function Pointers for Methods?

BlitzMax Forums/BlitzMax Programming/Function Pointers for Methods?

Since methods are really just functions with an extra hidden parameter you can create a "method pointer" of sorts.

SuperStrict

Type Test
	Field x:Int
	
	Function dummy(i:Int)
	EndFunction
	
	Method get:Int()
		Return x
	EndMethod
	
EndType

Local t:Test = New Test
Local p:Test = New Test
t.x = 5
p.x = 17

Local methGet:Int(o:Test)
Local temp:Byte Ptr = Test.dummy

methGet = Byte Ptr(Int(temp) + 12)

Print methGet(t)
Print methGet(p)


Of course it defeats the whole purpose of havimg methods since you can't use the nice dot syntax. Not to mention asking for a couple hundred unhandled memory exceptions