Method Pointers, How Difficult....

BlitzMax Forums/BlitzMax Programming/Method Pointers, How Difficult....

Arcadenut(Posted 2005) [#1]
Mark,

How difficult would it be to add support for Method pointers? Basically, I'm trying to create events in my classes.

here is what it might look like....

type TMyTypeA
	Field MyTypeB: TMyTypeB
	
	method New()
		MyTypeB = new TMyTypeB
		MyTypeB.MyEvent = Self.ResetSomthing()
	End Method
	
	method ResetSomething()
		' does something....
	End Method
	
	Method ThisGetsCalledAlot()
		MyTypeB.MyFunction()
	End Method
		
End Type

type TMyTypeB
	Field MyEvent
	
	method MyFunction()
		if Blah = True then
			if MyEvent then
				MyEvent()
			end if
		EndIf
	End Method
End Type



I can work around it, it's just not as clean when designing classes that shouldn't know about Parent objects. I usually work around it by creating a Message Class that ALL classes have a pointer to. However, this gets ugly and requires something to process that list of messages.

The problem with Function Pointers is that they are not tied to an instance of an object. I need something that is tied to an instance of an object.


N(Posted 2005) [#2]
http://www.blitzbasic.com/Community/posts.php?topic=42131

I'd take a look at that.


Arcadenut(Posted 2005) [#3]
Thanks