-
Notifications
You must be signed in to change notification settings - Fork 385
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
feat(examples): add rolist #3400
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: moul <94029+moul@users.noreply.github.com>
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
Signed-off-by: moul <94029+moul@users.noreply.github.com>
Signed-off-by: moul <94029+moul@users.noreply.github.com>
Signed-off-by: moul <94029+moul@users.noreply.github.com>
@@ -0,0 +1,119 @@ | |||
// Package rolist provides a read-only wrapper for list.List with safe value transformation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is list.list
exactly? It's not obvious from this package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's the gno.land/p/demo/avl/list.List
struct.
// // Create and populate the original list | ||
// privateList := list.New() | ||
// privateList.Append(&User{ | ||
// Name: "Alice", | ||
// Balance: 100, | ||
// Internal: "sensitive", | ||
// }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we're deviating from what we generally want with avl
. If someone wants to use a tree, let them use avl
and its helpers. If not, they're welcome to use the native slice. I think people won't understand when to use the native slice vs this kind of package, with an underlying avl
tree.
If the point of using this kind of package because of the "safe" functionality, maybe this package should be named differently & not be under avl
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes and no. For instance, I've opened an alternative version of an efficient structure to manage lists here: #3407.
However, the comments on my PR suggest there may be valid reasons to use the avl/list
(the main one is about soft vs hard delete). Additionally, the alternative aims to embrace the Unix philosophy and Golang composability, demonstrating that we can build layers upon layers.
I plan to use my #3407 alternative in most cases. However, some people are still using a standard AVL map as a list; I believe you're doing this too for the hof
realm, for example. Whenever you see someone using an avl.Tree with a seqid, there's a good chance they will prefer this package. For others, my ulist
alternative might be a better fit.
I believe we should have such packages, but we need to:
- Include great comments (let me know if I should improve them here or elsewhere).
- Provide excellent examples—let's create more
r/docs
, including one comprehensive guide for all the data structures for easier comparison.
avl/rolist
I...
interfaces foravl/...
's main structs.