Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

10
  • 1
    It's not magic. It simply captures the environment. The problem here and with for loops, is that the capture variable gets mutated (re-assigned). Commented Feb 4, 2009 at 16:58
  • 2
    leppie: the compiler generates code for you, and it's not easy to see in general what code this is exactly. This is the definition of compiler magic if ever there was one. Commented Feb 4, 2009 at 17:11
  • 4
    @leppie: I'm with Konrad here. The lengths the compiler goes to feel like magic, and although the semantics are clearly defined they're not well understood. What's the old saying about anything not well understood being comparable to magic? Commented Feb 4, 2009 at 17:22
  • 2
    @Jon Skeet Do you mean "any sufficiently advanced technology is indistinguishable from magic" en.wikipedia.org/wiki/Clarke%27s_three_laws :) Commented Feb 4, 2009 at 18:17
  • 2
    It does not point to a reference. It is a reference. It points to the same object, but it is a different reference. Commented May 4, 2009 at 9:07