Skip to content

Comment on C# to take a breaking change in version 5parent

Comments

Thanks 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.

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.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.