Skip to content

Conversation

@mgeier
Copy link
Member

@mgeier mgeier commented May 23, 2015

Currently, all methods to set client callbacks (jack.Client.set_*_callback()) have an optional userdata argument. This was meant to mimic the "void* arg" argument in the JACK API, but this argument isn't actually used in the implementation. Instead, the userdata argument is implemented by using a Python closure (callback_wrapper()), which avoids converting the value to a void* and back.

I think the argument userdata will probably never be used, because users of the library can just create a closure themselves and use it as callback function.

The advantage of dumping userdata would be that the function signatures of the callback functions would become much easier to understand.
Also, users wouldn't be forced to add the userdata argument to their callback functions even if they know they will never use it, which IMHO is quite annoying.

Are there any disadvantages?

I think the userdata argument only adds confusion and nuisance and doesn't help anyone.

Is there any conceivable use case which cannot be implemented without the userdata argument?

@mgeier mgeier added this to the 0.3.0 milestone May 20, 2015
@mgeier mgeier removed the question label May 20, 2015
@mgeier mgeier changed the title Get rid of "userdata"? Get rid of "userdata" May 20, 2015
@amstan
Copy link
Contributor

amstan commented May 23, 2015

This is a good idea.

Is there any conceivable use case which cannot be implemented without the userdata argument?

I think userdata only exists in jack because in C you don't really have lambdas and such.

@mgeier mgeier merged commit 8f8916a into master May 23, 2015
@mgeier mgeier deleted the issue-7 branch May 23, 2015 10:14
@mgeier mgeier mentioned this pull request Jul 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants