[polyml] Lifespan of pointers to callback functions passed via C FFI

2012-01-27 Thread Phil Clayton
I have been assuming that the pointer back to an ML function passed to a foreign C function will still be valid after the C function has returned, so the callback can occur sometime later (from a different C function). Is that a valid assumption? I made this assumption based on some tests in

Re: [polyml] Lifespan of pointers to callback functions passed via C FFI

2012-01-27 Thread David Matthews
Phil, Currently, callbacks remain in effect for ever and are never garbage-collected. I've certainly come across cases where I would want a callback to remain in effect after the function that passed it in had returned. For example, the window procedure in RegisterClassEx in Windows. I don'

Re: [polyml] Lifespan of pointers to callback functions passed via C FFI

2012-01-27 Thread Phil Clayton
David, Thanks, that's good to know. Thinking about explicitly deleting callbacks led me to ask whether each ML function passed as a callback has its callback reused on subsequent calls. If reuse occurs, the number of call sites in the source code would bound memory usage. I'm guessing that

Re: [polyml] Lifespan of pointers to callback functions passed via C FFI

2012-01-29 Thread David Matthews
On 27/01/2012 20:15, Phil Clayton wrote: Thinking about explicitly deleting callbacks led me to ask whether each ML function passed as a callback has its callback reused on subsequent calls. If reuse occurs, the number of call sites in the source code would bound memory usage. I'm guessing that

Re: [polyml] Lifespan of pointers to callback functions passed via C FFI

2012-02-01 Thread Phil Clayton
On 29/01/12 15:57, David Matthews wrote: On 27/01/2012 20:15, Phil Clayton wrote: Thinking about explicitly deleting callbacks led me to ask whether each ML function passed as a callback has its callback reused on subsequent calls. If reuse occurs, the number of call sites in the source code wou

Re: [polyml] Lifespan of pointers to callback functions passed via C FFI

2012-08-13 Thread Phil Clayton
On 01/02/12 10:44, Phil Clayton wrote: On 29/01/12 15:57, David Matthews wrote: On 27/01/2012 20:15, Phil Clayton wrote: Thinking about explicitly deleting callbacks led me to ask whether each ML function passed as a callback has its callback reused on subsequent calls. If reuse occurs, the num