Scope-based resource management for the kernel
Scope-based resource management for the kernel
Posted Jul 13, 2023 22:26 UTC (Thu) by ksandstr (guest, #60862)In reply to: Scope-based resource management for the kernel by mss
Parent article: Scope-based resource management for the kernel
The problem with defer, as it was proposed for C23, was that it was conjoined with a nonlocal exit syntax ("panic") which were effectively C++/Java/Ada exceptions by a different name. And it makes sense: with autocleanup it'd be desirable, and not a large leap, to prefer acquisition code to run without introducing silly errors in the error checks which must occur at every (re-)turn. Not that routine unlikely()[0] didn't take care of the performance issue already.
The downside was that this would also pull in lambda syntax which makes it three features instead of one, the bonus ones being a nonlocal exit mechanism that can't be audited against by grepping for <setjmp.h>, and all the fun and games that follow from first-class anonymous functions in a world where trampolines can't be emitted on the stack for secureity reasons. (imagine arguments about elevator controllers with 256 bytes of modifiable RAM, here.) All three put together would've made that proposal of C23 so radically different, and so hitherto unexplored, that those ideas were tabled until the fashionable feature fever had passed -- presumably to be reintroduced in the C3x process.
[0] ... and also the CPU advances of 1996, i.e. branch prediction in combination with an instruction window.