4 ms·
No. Closures, if implemented properly, may contain references to variables in the enclosing lexical environment where the closure was defined. Whether they liv
by bitwize 17y ago
No. Closures, if implemented properly, may contain references to variables in the enclosing lexical environment where the closure was defined.
Whether they live on the stack or in the heap is an implementation detail, and may have everything to do with the provable dynamic extent of the closure (e.g., downward funargs can point back onto the stack whereas upward funargs must be heap-allocated).