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.
In reply to Re^8: Yet Another Program on Closures ~ Steven Lembark ~ TPRC 2025 - YouTube
by ikegami
in thread Yet Another Program on Closures ~ Steven Lembark ~ TPRC 2025 - YouTube
by LanX
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |