3 ms·
(C/OS developer spiel) I'm sick of these app developers assuming that using "goto" is bad practice. The fact is that "goto" is used plenty in great production
by dantle 13y ago
(C/OS developer spiel)
I'm sick of these app developers assuming that using "goto" is bad practice. The fact is that "goto" is used plenty in great production code you're probably running right now.[1] I'd like to know a cleaner way to abort a function into its cleanup phase when a function call returns an error. And "goto" statements are extremely simple to handle for even the most naive of compilers.
[1] https://www.kernel.org/doc/Documentation/CodingStyle https://www.kernel.org/doc/Documentation/CodingStyle (see chapter 7)
- pjmlp 13y agoExceptions
- Niten 13y agoNot terribly plausible in kernel code.
- pjmlp 13y agoNot all kernels are UNIX.
- dantle 13y agoI didn't know UNIX won't allow kernel exception handling. Source? Of course exceptions are suboptimal; bad performance compared to "goto" can have unintended side effects depending upon the OS (scheduling work may be triggered off of the additional interrupt).
- pjmlp 13y ago> I didn't know UNIX won't allow kernel exception handling. Source? My statement was based on ideology as I doubt typical UNIX kernel coders would ever allow for exceptions, given that C does not support them and is against the UNIX way. > Of course exceptions are suboptimal; bad performance compared to "goto" can have unintended side effects depending upon the OS (scheduling work may be triggered off of the additional interrupt). Exceptions at the kernel level are possible, Windows does it for certain classes of errors, for example. Some other commercial or research kernels might do it as well.