pybind11 syntax alternative #281
pavlis
started this conversation in
Design & Development
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was trying to solve a pybind11 problem I was having, the details of which aren't relevant to this discussion, and ran across this interesting example:
I only point it out because although it is a bit more verbose, the syntax is far less obscure than the way our files are laid out following guidance from the pybind11 docs. For readers not familiar with this issue, the pybind11 docs would have laid this out (in a more skeleton form) more like this:
I suspect we would have fewer syntax headaches if we used the structure in the example above compared to the way the pybind11 docs suggest doing this. Specifying the ".def" items and individual C++ code lines would reduce the problems with getting the C++ punctuation (i.e. closing {}, [], and () pairs) correct. Early on I especially struggled with that because I hadn't yet realized how a single misplaced punctuation could cause a cascade with pages of compiler errors. Following this syntax might reduce such errors.
This may be something to consider retrofitting down the road to help maintain the C++ code base. Add comments as you see fit below. If you all concur I think we should add this picky job to our development agenda. Taking on the job would be a good task a new developer who needed to learn pybind11. The act of editing the existing pybind11 code to this alternative structure would be a good tool for teaching all the oddities of pybind11.
Beta Was this translation helpful? Give feedback.
All reactions