To be blunt, the code you copied out as example is crap. I don't know what you expect how it's being interpreted. It says more about the programmer than the language.
> functions returning closures with mutable captures
That sounds like another bad design, but to each his own.