Get Byte ptr to type method ?

BlitzMax Forums/BlitzMax Programming/Get Byte ptr to type method ?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.


Just for the sake of asking, why isn't it doable?



Well, revise that - it's doable, just a little tricky. Ideally, you just want to be able to go:

Local SomeFun(x)=obj.SomeMethod

SomeFun( 10 )

However, to implement this, 'SomeFun' needs to store 64 bits worth of info: a pointer to the 'obj', and a pointer to the 'SomeMethod', as 'SomeMethod' will likely need 'obj' (it's 'Self') - ie: the SomeFun(10) call is really obj.SomeFun(10).

This of course totally messes up 'normal' function calls, so you get into the territory of having to invent a new construct for 'method pointers'. These are commonly called 'delegates' in other languages.

Personally, I'd much rather see function pointers and delegates unified, but am yet to think of a way to do it 'nicely'. Its one of many things I will likely take another look at one day.