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

Break all iterators by false return #693

Open
cthulhu-rider opened this issue Mar 10, 2025 · 3 comments
Open

Break all iterators by false return #693

cthulhu-rider opened this issue Mar 10, 2025 · 3 comments
Assignees
Labels
enhancement Improving existing functionality I3 Minimal impact S3 Minimally significant U3 Regular
Milestone

Comments

@cthulhu-rider
Copy link
Contributor

with Go 1.23, iterators became extremely powerful. We already had some even before

sometimes iterator cannot be used with for range directly due to breaking condition. For example, https://pkg.go.dev/github.com/nspcc-dev/neofs-sdk-go@v1.0.0-rc.13/netmap#NodeInfo.IterateNetworkEndpoints breaks on true while for requires false. This can be solved via wrapper:

for endpoint := range func(f func(string) bool) { node.IterateNetworkEndpoints(func(s string) bool { return !f(s) }) } {
		cmd.Printf("%s ", endpoint)
	}

i propose to provide iterators with inverted behavior

@cthulhu-rider cthulhu-rider added enhancement Improving existing functionality I4 No visible changes S4 Routine U4 Nothing urgent labels Mar 10, 2025
@roman-khimov
Copy link
Member

As much as I don't like breaking changes I think we better follow the upstream here, it's a standard now and being off this standard makes the library inconvenient to use. But the change is quite radical and we need new method/function names at the same time I think, otherwise people will upgrade SDK and not notice this change until it breaks in some way.

@roman-khimov roman-khimov added this to the v1.0.0 milestone Mar 10, 2025
@roman-khimov roman-khimov added U3 Regular S3 Minimally significant I3 Minimal impact and removed U4 Nothing urgent S4 Routine I4 No visible changes labels Mar 10, 2025
@cthulhu-rider
Copy link
Contributor Author

provide iterators with inverted behavior

i meant new ones

@roman-khimov
Copy link
Member

We can just provide All() iter.Seq and alike now instead of IterateXXX (proper naming is suggested by https://pkg.go.dev/iter).

@cthulhu-rider cthulhu-rider self-assigned this Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improving existing functionality I3 Minimal impact S3 Minimally significant U3 Regular
Projects
None yet
Development

No branches or pull requests

2 participants