[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: variables in yyparse

From: Hans Aberg
Subject: Re: variables in yyparse
Date: Sat, 18 Dec 2004 19:41:44 +0100
User-agent: Microsoft-Outlook-Express-Macintosh-Edition/5.0.6

At 00:39 +0100 2004/12/18, Laurence Finston wrote:
>>> The code for handling error exits
>>> from the functions and thrown exceptions has to be in the
>>> rules, though, so there's a limit to how much putting code
>>> into functions helps.
>> Why would C++ exceptions have to be throwed directly from the rule
>> actions, and not in functions called from these?
>Allocation is performed both in rule actions and in functions called from
>them.  In more recent code, I always call `new' in a `try' block and catch
>`bad_alloc'.  I'm in the process of revising old code so that I do this
>everywhere.  Where functions called from rules call `new', I wrap the calls to
>those functions in `try' blocks, catch `bad_alloc', issue an error message,
>possibly perform some clean-up, and rethrow `bad_alloc'.

I still do not see why you have to throw exceptions without the functions.
If you do not have a good memory recover, a bad_alloc usually means that the
whole program is toast. So recovery need to be somewhere where both memory
can be reclaimed and the failed code can be rerun.

  Hans Aberg

reply via email to

[Prev in Thread] Current Thread [Next in Thread]