3 ms·
How could lambdas make sense in C? Keeping closures around means having to keep free variables around. C doesn't have garbage collection, so it would be quite a
by gcr 13y ago
How could lambdas make sense in C? Keeping closures around means having to keep free variables around. C doesn't have garbage collection, so it would be quite awkward to establish conventions about who gets to free the variables that each closure references.
- betterunix 13y agoHow does any of that not apply to C++?
- deleted 13y ago[deleted]
- kybernetyk 13y agoClosures work pretty great with std::shared_ptr.
- betterunix 13y agoUnless you have a cycle.
- JoshTriplett 13y agoTake a look at the "blocks" extension to C, in LLVM. It includes mechanisms to handle the lifetime issues, though it does still require explicit memory reclamation of blocks.