Comment on C# to take a breaking change in version 5parentComments−sbi14yThanks for pointing that out. I would have guessed that the original form would desugar to map(lambda i: (lambda: i), xrange(10)) but apparently it doesn't.−ot14yExactly, it desugars to something like a for loop, in fact the iteration variable remains visible in the outer scope (other possible source of confusion).I believe it doesn't desugar to a map+lambda for performance reasons.−baq14yif it desugared to map, you could redefine map() and unleash all kinds of hell on yourself inadvertently.
Comments
Thanks for pointing that out. I would have guessed that the original form would desugar to
but apparently it doesn't.Exactly, it desugars to something like a for loop, in fact the iteration variable remains visible in the outer scope (other possible source of confusion).
I believe it doesn't desugar to a map+lambda for performance reasons.
if it desugared to map, you could redefine map() and unleash all kinds of hell on yourself inadvertently.