> I'm surprised noone answered OP's question so far. The question was why the code shown by the OP wasn't possible in Nim. :-)
> Since Nim is not a functional, but imperative language, I think we shouldn't think too much in language categories. If a language is mostly imperative, this doesn't mean that it can't have features that are _typically_ found in functional languages. For example, several "imperative" languages have list comprehensions (or something similar), "even though" this is a feature coming from functional languages, as far as I know. Or think about Nim's side effect tracking. Just to clarify: I'm not suggesting that Nim should support every feature from other programming languages. (I'm glad it doesn't.) But I suggest being more open and not avoiding to think about features in Nim because "they're functional language features." I think you could potentially have "every" feature in Nim as long as it fits within the overall design.
