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

Tree lenses #30

Open
cfhammill opened this issue Oct 24, 2018 · 1 comment
Open

Tree lenses #30

cfhammill opened this issue Oct 24, 2018 · 1 comment

Comments

@cfhammill
Copy link
Owner

cfhammill commented Oct 24, 2018

I find data.tree cumbersome because of mutation. I want a library free of this inconvenience, but it does a lot of nice things I would miss. Convenient print methods, easy data.frame conversion, automatic ancestry/depth tracking. I am torn between writing lenses for data.tree and writing a simpler tree library built around a lens API. Provided I write simple conversions between the two we could potentially have the best of both worlds.

Writing lenses for data.tree would involve checking to see if the lens is pointing at a node, following the node's ancestry to the tree root, and triggering a full copy on set. It is possible I'm over-estimating the performance problems associated with this. R triggers full list copies on modify too, although I suspect R is making very smart choices about copying/GC that make it dramatically faster than copying data.trees (although I should really test).

Hacking a tree API seems easier to me than optimizing copy speed or decreasing copy frequency in data.tree but involves writing a lot more code.

Decisions, decisions.

@cfhammill
Copy link
Owner Author

cc: @jasonlerch

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

1 participant