3 ms·
Not all closures require heap allocation.
by jjnoakes 11y ago
Not all closures require heap allocation.
- gdwatson 11y agoEnriquto asked for closures which remain valid after the enclosing function has returned — upward funargs. If the closed-over variables need to survive the parent’s stack frame, where else would you put them?
- jjnoakes 11y agoThe variables could be static, or optimized away, or... I'm not saying every closure can be done without allocation. I'm saying many useful ones can be though.