4 ms·
That would require implicit heap allocation, which is a lot to ask for in a language where malloc is a library function.
by gdwatson 11y ago
That would require implicit heap allocation, which is a lot to ask for in a language where malloc is a library function.
- jjnoakes 11y agoNot 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.