@ ne555, I would still say it depends on environment. For a webserver, restarting the server to cut off idle connections is easily ideal compared to chrisname's solution. In a type of server meant for long-term connections where the client user might go away and expect to still be connected, then I might agree.
> I would still say it depends on environment
in an environment were a good approach is simply to wait, ¿how would you do it?
iirc yield would put the process as idle not blocking ¿is there a way to block the process, maybe touching setting of the OS?
"In modern computing terminology, a kludge (or often a "hack") is a solution to a problem, doing a task, or fixing a system that is inefficient, inelegant, or even unfathomable, but which nevertheless (more or less) works."
How is "an exception is thrown" complicated? If anything, I'd say it's a rather elegant solution to the problem. You have a stack of the form foo() -> [external code] -> bar(), where bar() never returns, and you want to ensure that resources allocated by the external code are released. Is there a simpler solution than exceptions?
The cleanup of resources isn't what I'd call "little gain". Some resources, such as automatic locks on mutexes, must absolutely, positively be released, and if some functions aren't guaranteed to ever return, guaranteeing that becomes rather complicated.
I'm not arguing whether it's a hack. It's obviously one, as it uses a feature in a way it's not intended. I'm asking how that fact is opposed to what I said, that exceptions can be extremely useful to redirect control flow.
It seems like a good solution to me. It may be hackish and unusual but it's not like it's exploiting undefined behaviour (which would be unsafe and unportable) and it sounds like other ways of achieving the same thing would be more complicated, and possibly thereby less safe, less portable, or less maintainable. It makes sense to use the exception mechanism there. But, like helios said, it's only in very specific circumstances -- in the general case, exceptions are for indicating specific error conditions.
okay, ne555 your suggestion about the string hierarchy has now been implemented. Related menus now only require the parent string id to be given to the child; the parent scans the menu list to find a child menu with its string id in order to execute the right menu.
Not quite ready to release it just yet though, I want another day or so to double check everything and add a few features. Does anyone know of a non-OS dependant way of setting command line colour? I have heard that system() calls are not the best idea, but I don't want to use the Windows API for this (and break portability in the process)
Honestly, I wasn't aware that it was inactive. Even if I had been, it'd take more than merely being inactive to get me to recommend a GPL project over a public domain one. Like dispensing live wasps or something. :-)