Re: Try/Catch
- Posted by Shian_Lee Jan 04, 2015
- 6146 views
My position is, as a matter of principle, when the language can get away with returning an error code from a routine to signal something, it should do so. If it's something that can't be reasonably handled by a routine returning an error code, that's when it's time to consider throwing an exception....
I feel the same.
If possible, current procedures, such as puts(), may or may-not return error status; this will not break existing code. for example:
puts(fn, "...") -- can be used for demos, simple programs, anything...
ok = puts(fn, "...") -- can be used for more critical data.
About exception handling: before adding such a huge headache to Euphoria, it's better to consider carefully the need for it, and the way that most programmers will use it eventually.
Personally, I'm not sure that I can think about a good example for using an error handler. And cleaning up code can be done in many ways, depends on the situation.