Pointers to functions
darco
Posts: 86
I'd like to be able to pass a pointer to a function to another function, which can then call that function a number of times with different parameters. I'm very comfortable with pointers in C, but the syntax of this language is really making my head.......spin.
Is it possible to execute a given function if you have a pointer to it? If so, what is the syntax to do this in Spin?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
—
darco
www.deepdarc.com/
[url=mailto:xmpp:darco@deepdarc.com]xmpp:darco@deepdarc.com[/url]
Is it possible to execute a given function if you have a pointer to it? If so, what is the syntax to do this in Spin?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
—
darco
www.deepdarc.com/
[url=mailto:xmpp:darco@deepdarc.com]xmpp:darco@deepdarc.com[/url]
Comments
-Phil
To answer your question more directly: There are no pointers to functions in Spin and you can't execute a function given a pointer. That said, it is possible to "fool" the interpreter as Phil has done, to locate the internal tables used to point to the actual interpretive code for a function and to "patch" them with the address of a different block of interpretive code so that the new piece of code is executed in place of the compiled one.