When does for call the iterator method?
This question is in the same ballpark as this other on making blocks iterable , but seems to reveal a different problem with mixins (or a different misunderstanding of the syntax on my part). What Iterable does is to make a data structure effectively iterable, that is, you can create loops by preceding it with for . Iterable serves as an API for objects that can be iterated with the for construct and related iteration constructs, like hyper operators. So let's try to put this to practice: my &logger = -> $event { state %store; if ( $event ) { %store{ DateTime.new( now ) } = $event; } else {