flag or exception?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

flag or exception?

Bee-6
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?

TIA.

-Bee-

has Bee.ography at:
http://beeography.wordpress.com
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: flag or exception?

Micha Nelissen
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.

Micha
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: flag or exception?

Michael Van Canneyt
In reply to this post by Bee-6


On Fri, 1 Sep 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?

This is highly developer dependent.

I personally prefer exception-based code.
I find it more clear and readable (less IF's), and more structured
(easier cleanup in case of error, etc.)

But this is a personal opinion.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: flag or exception?

Bee-6
In reply to this post by Micha Nelissen
> Depends on taste, and they have both advantages and disadvantages.

I've been googling for this subject, but so far I can't find any satisfying
explanation about the advantages and disadvantages of each mechanism or a
comprehensive comparison between the two.

Any URL for this? TIA.

-Bee-

has Bee.ography at:
http://beeography.wordpress.com

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal