OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: [xml-dev] The subsetting has begun

[ Lists Home | Date Index | Thread Index ]

On Saturday 22 February 2003 05:41, Karl Waclawek wrote:
> > Karl Waclawek scripsit:
> > > Maybe that is different for Java, but in general this is simply wrong.
> >
> > If you mean "in C++", say so, not "in general".
> No, I do mean: to say that using exceptions for common program flow
> control is what they are meant for, is not true in general.

Well there's no fixed dividing line between exception conditions and common 
program flow. You could say that exceptions are only for truly exceptional 
conditions such as stack overflow and hardware failure, and everything else 
should be handled by error returns... but I think few would necessarily 
agree. On the other hand you could say that, in a while loop, the normal flow 
is to repeat and it's exception to escape; if the average while loop does a 
hundred iterations then it ony stops iterating 1% of the time, which is 
pretty exceptional. Then one could write loops like this:

loop {


    if (command = "STOP") break;


Many languages have just that construct. "break" is a nonlocal exit, just 
like throw / catch.

Then you have continuation-passing languages where procedure return points 
are first class objects; you explicitly pass the return address into a 
procedure, and there's nothing stopping you from passing in several, one for 
success and one for each different kind of failure, that return to different 
points in the stack.

*shrug* I think it's difficult to argue at what point a flow of control 
becomes 'exceptional'. I'm in favour of not having religious wars about it 
and just using whatever construct is most appropriate at each point in my 
code :-)

> This is no intuition. I can whip up a quick demo in Delphi
> (I already did - took 5 minutes) which shows that passing a Boolean result
> up from a 5 levels deep nested procedure call executed in a loop is at
> least 100 times as fast as throwing and catching an exception for the same
> purpose. I can post or e-mail it if you really want to see it.

Is that under Windows? ISTR that Windows has to handle some part of exception 
handling itself for some obscure reason and makes it awful slow?

Exeptions don't *need* to be slow. There are fast implementations.

> Karl


Oh, pilot of the storm who leaves no trace, Like thoughts inside a dream
Heed the path that led me to that place, Yellow desert screen


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS