Offline repost: thoughts about catching exceptions without exceptions

I'm usually a rather careful programmer if something has to work properly. Still, when I'm pumping code cause it needs to be done fast, I won't check every single possible problem, especially if it's about acquiring system objects or memory allocation. However, I build my own ternary logic to convert every single boolean success/fail value from every function call to provide a quick look from upper layers whether something failed, succeeded or only partially functioning. However, this does in all cases require strict and consistent discipline and also not less code to write since C's macros are limited if it comes to dynamic parameters... wait. Wasn't there something like that? Hm... Anyway, I'd need to collect a lot of variables and I'm not exactly fond of doing so. Having programmed in both Erlang and Prolog, they offer very convenient features because they provide ways to return/inform when even a single function failed (though Prolog uses it to backtrack and in Erlang for terminating). Taking this as inspiration, I'd like to have some sort of system where everything I do would evaluate in either true or false OR in it's return value! Just think about: you'd only pump all calls to functions or mnenomics for initalization, involve to results of branches, conditions and so on and you'd exactly you know way it went correct, where something failed a bit and where the real problem was. You could use those paths for debugging and reconstructing problems in a fully compiled program and use during development process, too! I'll start a small set of macros and look whether they would be of use in C, where such a functionality is not included. Now I'm really curious whether there's a lnaguage out beeing capable of atleast providing a portion of that. I'd also be happy with some simple "precondition" functionality returning when parameters got wrong values and so on. However, I guess I can write these on my own and also implement the bool-for-every-function thing with macros and static memory... Yeah, I think that this might be a good idea. Could make some very convenient system cause I currently want have exactly such a thing before continuing.

No comments: