Skip to content
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

Property delete option #21

Closed
jakirkham opened this issue Dec 4, 2015 · 3 comments
Closed

Property delete option #21

jakirkham opened this issue Dec 4, 2015 · 3 comments

Comments

@jakirkham
Copy link
Contributor

I was wondering about your thoughts on having def_property (and friends) take a fdel parameter to be called when the property is deleted.

@wjakob
Copy link
Member

wjakob commented 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
Copy link
Contributor Author

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.

@wjakob
Copy link
Member

wjakob commented 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).

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

No branches or pull requests

2 participants