Request: Method Pointers

BlitzMax Forums/BlitzMax Programming/Request: Method Pointers

Bot Builder(Posted 2005) [#1]
Ok, I know this has been discussed before, and i have been one of the naysayers, however, my idea is different from the oens before. Instead of the pointer being tied to a specific instance (slow), the pointer simply points at the internal function and you pass the type you are operating on as the first parameter. The reason I want this is that I have realized that the best way to write my interpreter with the possibility of using internal functions/types, etc is to use pointers. For instance:

RegisterFunction("SetRotation(Rotation#)",SetRotation)

Actually, I'll still facce obsticles even with doing this because there is no way to know how many parameters there are except at run time.... Okay, another suggestion - allow passing of a special type of array instead of the parameters. This array would hold the values you wish to pass into the parameters. It doesnt matter if this system throws an error on variable incompatability or incorrect number - aslong as i can catch it as well ;) I know, tall order, BRL, but it'd allow for a really cool interpreter system.


ImaginaryHuman(Posted 2005) [#2]
I had an interpreter system in mind where I would need the function pointer to a method, but I would need to not pass any parameters. But it looks like the only viable solutions would involve passing a parameter, so that's out the window. Still undecided how to do that.


Bot Builder(Posted 2005) [#3]
Yep. I bet blitzmax actually has functions rather than methods internally, so that part of it would be viable. The part about passing passing parameters without even knowing how many or what parameters there are could be tricky, but it would make mine, and probably angeldaniel's interpreter really elegant. It would also allow me to track usage. So, if someone made something like coolbasic with my interpreter (this would be disalowed in the EULA or something), you would be able to detect it since I am only going to release it as a module, no source. Since modules are already compiled, something like my module, or atleast very very similar will appear in an exe using it. Anyway, I'll jsut keep coding, and maybe something can be done. I guess, if not, I could try a system like bvm with a stack of parameters that gets pushed and popped, and a bmx file generated out of the required commands that will Pop in parameters, and poke out values.


skn3(Posted 2005) [#4]
Of course you could always just do it yourself, by making the first param of your type function ,the object you wish to pass.


ImaginaryHuman(Posted 2005) [#5]
That's one way, but you can have functions with no parameters - a feature that would be useful for referring to methods too. I can see how to force an address into a function pointer but acquiring the pointer to the method is the tricky bit.