Content deleted Content added
→top: move upvar from closure, since just a synonym for this (else not relevant for closures) |
|||
Line 42:
If the nested function is passed as an argument to a higher-order function a [[closure (computer science)|closure]] needs to be built in order to locate the non-local variables. If the nested function is returned as a result from its outer function (or stored in a variable) the non-local variables will no longer be available on the stack. They need to be heap allocated instead, and their lifetime extend beyond the lifetime of the outer function that declared and allocated them. This generally requires garbage-collection.
==Notes==
{{reflist}}
== References ==
* Aho, Lam, Sethi, and Ullman. "7.3 Access to Nonlocal Data on the Stack". ''[[Compilers: Principles, Techniques, & Tools]]''. Second edition.
|