search “java iterator”
boom. done. You have a direct path to all the iterators and their construction and usage.
c++ iterator
search “julia iterator”
using the JL internal search yields a mess (discussed shortly)
I found the
next = iterate(iter)
while next !== nothing
(i, state) = next
# body
next = iterate(iter, state)
end
example in substack after 20 minutes of poking around in JL documentation. Even so, I had to fiddle with search terms in order to find the question and answer with the usage example you presented.
discussion:
My chief difficulty is I need to know in advance where the topic is filed under.
If you go to the base documentation
and type “iterators” then click on the the hopefully named Base.iterators all the reader is presented with is “there’s a module named iterators”
fine.
The side panel is dominated ESSENTIALS section presented contains a long list of not the thing I need. Below it, obscured under the mass of essentials, is Collections and Data Structures, followed Mathematics, Numbers which are all not the topic I am searching for. In terms of search results that side panel quickly looks like it’s not relative relevant to the search I just made.
The distinguishing factor in the first two language examples is I am presented with information that allows me to do the thing I need to.
In JL the usage is explained in passing
Further, if I had known to search for iterate(), I would still have to infer the initialization as
iterate(thing)
and know the unpacking convention
(i, state) = next
AND iterate(thing, state) means next item
The actual documentation for iterate() leaves almost everything unsaid.
If my discussion here sounds a bit frustrated and cranky. It’s because it shouldn’t be this hard and hopefully is a useful explanation of why I found everything and find everything relatively more challenging to learn about in Julia. The smart alec way I would describe it is that JL documentation is orthogonal to almost all my expectations. With every other language I have worked with the chief advantage in beauty of Java was that the language designers decided to include a very direct template for class documentation for the fields for the methods for the arguments of the methods and an entire system that was used to generate a useful documentation tree so people could understand abstractions down to their implementations all provided there. I should know I worked with some of the principal people who developed the language. They put a lot of thought into this into making the programming environment of Java, deliberately accessible to what they would call the average programmer. They made it pretty darn clear and pretty darn easy also aided by the structure of the language itself to be quite explanatory in a very concise way.