Re: error handlling in recursive function
- From: "Malcolm McLean" <regniztar@xxxxxxxxxxxxxx>
- Date: Sat, 31 May 2008 13:52:13 +0100
"David Resnick" <lndresnick@xxxxxxxxx> wrote in message
MiniBasic has exactly this problem.A third option might be to have a global variable (at file scope)
that gets set if an error occurs. Ok, global variables are EVIL,
but this may be one of the cases where their use can simplify
things a bit...
Sure, and a fourth is to pass down a pointer to a variable to use for
error reporting. I gave the answer I did because I interpreted his
question as being also how to reasonably unwind the stack of recursive
invocations when hitting an error condition...
The solution is to have a sticky error. So once one error is set, all subsequent errors are suppressed. So the rest of the code can chug on, returning in its own good time - obviously you have to be a bit careful not to write to potentially null pointers and so on, but there is no reason to stop expression parsing jsut because a string wasn't allocated somewhere.
PS website contains important programming and scientific information. Someone please check availability for me.
--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm
.
- References:
- error handlling in recursive function
- From: pereges
- Re: error handlling in recursive function
- From: David Resnick
- Re: error handlling in recursive function
- From: Jens Thoms Toerring
- Re: error handlling in recursive function
- From: David Resnick
- error handlling in recursive function
- Prev by Date: Re: malloc()/realloc() - have I got this right?
- Next by Date: Re: replace substring
- Previous by thread: Re: error handlling in recursive function
- Next by thread: Re: error handlling in recursive function
- Index(es):