Regarding the second code snippet - I've never seen this language feature before. Obviously there are things sometimes called generators implemented as structures, where 'step' or 'next' is just a normal method, but is there a real world example of what is shown?