[fpc-pascal] flag or exception?
micha at neli.hopto.org
Fri Sep 1 12:32:54 CEST 2006
Bisma Jayadi wrote:
> Hi all...
> I've always been confused about this subject... flag or exception for
> error handling? Can anyone share knowledges and ideas about when and
> where and why a (pascal) developer should chose one over another?
Depends on taste, and they have both advantages and disadvantages.
For example, it's easy to see when flag-using code is coded correctly
(are the return values checked and handled?), while it's hard for
exception-using code. Exceptions are usually slower as well. Exceptions
are also not compatible to other languages, usually. OTOH, using
exceptions is lazier/easier. If an error should never occur, then using
exceptions will have more readable code, as not every function calling
this must handle the possible error flag.
More information about the fpc-pascal