-
Notifications
You must be signed in to change notification settings - Fork 70
Allow multiple add ons for the same class or namespace #331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Thank you for PR! Could you please elaborate on how this will be used? Is the main idea is to allow user to add separate functions? If so, what will be he call order of these functions? Also, could you please elaborate on how this will be better to just supplying a single function from which user can call other functions? |
|
Hey @lyskov,
Exactly that. I am structuring my binder config file in sections, with a small section for each header file of the code I am binding. So for header As for classes: Not sure if this is strictly needed as well, but I figured that while at it, I might as well implement that as well. At the least, silently overwriting previous add ons is unexpected, and this avoids that. I don't currently have a use case for classes, but others might.
In the order they are defined in the config. The PR just replaces the string with a vector, and adds all of them in order. Not more than that.
That would work as well I suppose, but would then not allow the setup above that allows for clear separation of concerns in the binder config, and instead would add a level of indirection for that function, which might be harder to trace and less flexible. Hope that clarifies it, and sounds useful :-) |
Could you please elaborate on that? Ie why defining extra-bindings-function definition somehow got tight-up to project source headers? Or do you place these extra-bindings-functions into project original headers, is that the idea? |
|
Not sure that I quite understand what you are asking.
My extra code needed for Binder is kept separate from my original project headers, to keep things as cleanly separated as I can. But in order to bring structure into this, I am "mirroring" the directory structure of the original code, and for each header that needs extra binding code also generate a header (and if needed source file) with the same name, which then contains the functions used for the For instance this and this line are both using Does that make sense? Or is there a cleaner way to do this? Either way, I think the functionality added here is reasonable, as otherwise, add-ons on the same namespace would silently overwrite each other, which is unexpected. |
|
Aha, - now I see your point, - thank you for explaining! Yes, this makes sense and I do agree that this will be useful. I will add the review shortly. |
lyskov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thank you @lczech ! A few things before we could merge this:
-- could you please add documentation for a new config option and update docs for existent one? Please particularly highlight calling order.
-- could you please add minimal test(s) for this? I imagine something simple like single namespace and single class inside it with both having two add-on-binders.
-- run all tests and double check that there is no unexpected changes.
Thanks,
|
@lczech bumping this PR, please see comments above. Thanks, |
|
Hi @lyskov, thanks for considering the PR! Unfortunately, I won't have time in the next couple of weeks to add your requested changes, but hope to get back to it towards the end of the year. |
Currently, when specifying the
add_on_binderoradd_on_binder_for_namespacetokens multiple times, later ones silently replace previous ones, which is unexpected. This PR extends this to capture multiple add ons, which can be useful to break them down into smaller pieces.