[Lazarus] exception handling

Bernd prof7bit at googlemail.com
Sat Mar 12 22:53:45 CET 2011


2011/3/9 Hans-Peter Diettrich <DrDiettrich1 at aol.com>:

> An exception down in some calculation doesn't give you any clue of what
> exactly went wrong, only that *something* went wrong.

It can often be useful and remove a lot of if/else for cleanly exiting
a bunch of nested loops and functions (and also save clock cycles and
make the code much more compact and clearer) if you let it
*automatically* unwind the the call stack (instead of writing code for
this) whenever the exception occurs (of course only if you really know
why your exceptions would occur).

Many people recommend not using exceptions as control structures but
IMHO exceptions *are* control structures and can (and should) be used
as such (if appropriate). In some other languages (Python for example)
this is even considered good programming style and recommended because
it can make certain code much cleaner and easier to understand.




More information about the Lazarus mailing list