This is not a well-documented topic, so the fact that you had a hard time finding it is not surprising.
Generator expressions are first-class objects, which allow you to decouple the generation from the collection in [ ... ]
expressions.
The promise of the ( .... for ... [if ...])
syntax is that you get something that conforms to the iteration interface. Consider it a shorthand for implementing simple custom iterators using mapping and filtering, mostly in a performant way (except for a few edge cases). A lot of this functionality overlaps with Base.Iterators
, predating that module.
Base.Generator
is the particular implementation for this. It is not exported, and (technically) it may change in the future. It is not good practice to use it unless you are prepared to update your code in case that happens. Incidentally, it is used to implement collect
and friends, but again that can change.