Skip to content

Property delete option #21

Closed
Closed

Description

@jakirkham

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

Activity

  1. wjakob commented on Dec 5, 2015

    @wjakob
    Member

    I'm not sure how useful it is for a binding library -- what does it mean to delete a property of a C++ class? :)

  2. jakirkham commented on Dec 7, 2015

    @jakirkham
    ContributorAuthor

    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.

  3. wjakob commented on Dec 7, 2015

    @wjakob
    Member

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

  4. added a commit that references this issue on Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions