What about iterators (and list comprehension) #11
serge-hulne
started this conversation in
Ideas
Replies: 2 comments
-
|
Iterators are definitely not planned for the foreseeable future. See the design principles. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I understand. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Go has long been missing iterators. This was a problem, because not every function call returns a value or an array with a fixed length, when one processes a stream or a long file, it is better to return an object that can be iterated on demand (lazily). Here was my take on iterators, before they were eventually implemented officially for Go:
https://serge-hulne.medium.com/iterators-map-filter-reduce-and-list-processing-in-go-golang-implementing-python-functional-2d24d780051f
https://github.com/serge-hulne/go_iter
My source of inspiration was the iterators and the "List comprehension" from Python.
Without that feature, streams and long lists cannot be processed elegantly and one has to resort to rather ugly constructs such as :
Instead of :
Beta Was this translation helpful? Give feedback.
All reactions