On Feb 24, 2009, at 12:58 AM, Anatoly A. Kazantsev wrote:

> On Mon, 23 Feb 2009 23:48:57 -0800
> Robert Bradshaw <[email protected]> wrote:
>
>
>> It's standard practice to have such void* arguments for callback
>> functions. Otherwise you'd have to store something globally and not
>> use two concurrently (which is obviously not ideal).
>
> Good practise :-)
>
> What about such:
>
> cpdef python_foo(python_callback):
>   cdef c_callback():
>     python_callback()
>
>   c_foo(c_callback)
>
> where c_foo and c_callback from some C lib.
>
> I know in cython function nesting is not implemented. But if it  
> was, is it possible
> to wrap callbacks this way?

Yes and no. The problem is that usually the callback needs to have a  
specified signature, and a closure created like that wouldn't (it  
would need its environment to be passed in when called as well).

- Robert


_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to