Thread View: comp.lang.misc
1 messages
1 total messages
Started by Johann 'Myrkraverk' Oskarsson
Wed, 21 Oct 2026 12:09
Re: “The end of software secrecy is almost upon
Author: Johann 'Myrkraverk' Oskarsson
Date: Wed, 21 Oct 2026 12:09
Date: Wed, 21 Oct 2026 12:09
54 lines
3943 bytes
3943 bytes
On 10/21/2026 7:18 AM, Charlie Gibbs wrote: > On 2026-10-20, Lawrence D’Oliveiro <ldo@nz.invalid> wrote: > >> On Tue, 20 Oct 2026 19:04:55 GMT, Charlie Gibbs wrote: >> >>> The undisciplined use of GOTOs is bad, agreed. >> >> Is there such a thing as a *disciplined* use of gotos? > > Yes, especially in COBOL or assembly language. For instance, > a GOTO to the end of a function ensures any of its cleanup code > gets executed, and fulfils a goal of structured proramming: > each function has one exit point. > >> I find the C code I write tends to do a lot of dynamic resource >> allocations. These can sometimes fail with errors. So error recovery >> will invariably involve cleaning up those parts of the allocations >> which already succeeded. Gotos are no good for this; you need to exit >> levels of structure nesting one by one, disposing of allocations as >> you go. > > I know that a lot of CS types are going to stick pins into little > dolls that look like me for saying this, but IMHO resource pointers, > handles, etc. should be global. Possible exceptions are resources > that are going to be used solely by the current function - but even > then, if that function calls another function that fails horribly, > there's stuff that might not get cleaned up. That's why all my > C programs contain a function quit_cleanup(char *errmsg), which > de-allocates all resources and then exits (displaying "errmsg" > if it isn't NULL). I can call that function anywhere, safe in > the knowledge that by the time it finishes (it never returns), > everything will have be freed. > Side note: I chose not to comment on any of the other followups by the less experienced coders. I personally have no problem with your app- roach. That works for a single process, but once you start making libraries like Lua that can be loaded and then unloaded the rules change somewhat. SQLite3 can be used similarly. Though I doubt many people load either library dynamically, and then un- load; yet as far as I'm aware, both libraries support such usage. I added comp.lang.misc because I'm not aware of a Lua discussion group. Best wishes, and happy resource cleanup! -- Johann | email: invalid -> com | http://www.myrkraverk.com/blog/ I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:; Federated at https://fed.brid.gy/bsky/myrkraverk.bsky.social
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads