2 ms·
> Besides, C programmers just won't use the feature if it requires allocation out of performance concerns. Nevermind embedded platforms where heap might be una
by foxfluff 5y ago
> Besides, C programmers just won't use the feature if it requires allocation out of performance concerns.
Nevermind embedded platforms where heap might be unavailable or just so scarce that its use beyond early initialization is strictly verboten. Or interrupt handlers where you simply can't call an allocator.. Block scoped defer could still be useful on such systems (e.g. with locks).
- gmfawcett 5y agoOf course. And if you were writing your embedded system in C++, you'd avoid EH and other non-zero-cost features. That doesn't mean that these features aren't useful in other contexts. I submit that the world of C and C++ programming is vastly larger and more diverse than the world of interrupt handlers and embedded systems. ...But as I pointed out in a sibling comment, I was never defending function-scoped defer. I agree with you. I was pointing out that the implementation of such a feature wouldn't require excessive stack allocation.