in reply to Re^7: Yet Another Program on Closures ~ Steven Lembark ~ TPRC 2025 - YouTube
in thread Yet Another Program on Closures ~ Steven Lembark ~ TPRC 2025 - YouTube

But a (the?) central idea of closures is that of encapsulation and protection of those variables from external manipulations and other side effects.

No, it's not about protection. Quite the opposite. Capturing allows a variable to be manipulated beyond its normal lifetime. That reduces the protection the variable has compared to one that wasn't captured.

Closures are about access and life-time. Capturing attaches data to functions. In a way, closures are similar to objects which attach functions to data.

  • Comment on Re^8: Yet Another Program on Closures ~ Steven Lembark ~ TPRC 2025 - YouTube

Replies are listed 'Best First'.
Re^9: Yet Another Program on Closures ~ Steven Lembark ~ TPRC 2025 - YouTube
by LanX (Saint) on Aug 04, 2025 at 20:47 UTC

      I have now. The paper/quote shows that the closure uses a captured environment ("binding environment") instead of the environment that exists where the closure is called ("activation environment"). The environment of a closure is therefore fixed ("closed"). And that this is the source of the name closure.

      Did *you* read it? Cause it defines a closure in terms of what variables it can access, just like I said.

        > Did you read it?

        Obviously!

        Anyway, my "no mono-threads below Re^10 because everything was already said at least twice" policy kicks in!

        See ya! :)

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        see Wikisyntax for the Monastery