You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm guessing your point is that one can't actually delete a member variable in C++. While this is true one could make it act like it was deleted on the C++ side.
For example, there could be a bool associated with the member variable that represents whether it exists or not. All getter, setter, and now deleter methods would check this bool to determine if the relevant variable is visible. If it is true, everything behaves the same. If it is false, the getter and deleter methods raise exceptions. The setter method is invariant to whether the variable is visible.
Behavior for deletion that deviates from this could be imagined like a no-op or reinitialization of the variable.
It feels like a somewhat niche use case -- I have not seen this kind of pattern before, especially not at the interface between C++ and Python. If you really need this feature, I would recommend that you fork the library (I'm trying to keep it to the essentials).
Activity
wjakob commentedon Dec 5, 2015
I'm not sure how useful it is for a binding library -- what does it mean to delete a property of a C++ class? :)
jakirkham commentedon Dec 7, 2015
I'm guessing your point is that one can't actually delete a member variable in C++. While this is true one could make it act like it was deleted on the C++ side.
For example, there could be a
boolassociated with the member variable that represents whether it exists or not. All getter, setter, and now deleter methods would check thisboolto determine if the relevant variable is visible. If it istrue, everything behaves the same. If it isfalse, the getter and deleter methods raise exceptions. The setter method is invariant to whether the variable is visible.Behavior for deletion that deviates from this could be imagined like a no-op or reinitialization of the variable.
wjakob commentedon Dec 7, 2015
It feels like a somewhat niche use case -- I have not seen this kind of pattern before, especially not at the interface between C++ and Python. If you really need this feature, I would recommend that you fork the library (I'm trying to keep it to the essentials).
PEP-518: pyproject.toml (pybind#21)