On 2009-09-24 22:27+0100 Andrew Ross wrote:

> On Thu, Sep 24, 2009 at 02:15:27PM -0700, Alan Irwin wrote:
>> Sorry for entering late to this conversation.  I may have missed some key
>> piece of information earlier in the thread, but let me ask a "dumb"
>> question, anyway. plexit ultimately calls exit, which AFAIK immediately
>> exits without returning control to the routine that called the plplot
>> library in the first place. So plexit should be reserved (and I think it
>> normally is) for truly catastrophic errors where no means exist to recover.
>> For that case where a castrophe is occurring anyway, why are we concerned
>> about memory management issues?  Why does plexit even bother to call plend?
>> Shouldn't it just send a message about the castrophic error and exit?
>
> Well only in the sense that it is good programming practice and will also
> do things like close file handles etc. I suppose you might manage to
> rescue part of a multipage plot if it had been properly closed...
>
> The question becomes much more important if you are going to do something
> in your exit handler, i.e. throw an exception, which means exit is _not_
> called.

That transfer of control part, is the part I didn't understand.  Although I
have very little C++ experience you got me interested enough to look at a
C++ tutorial on exceptions
(http://www.deitel.com/articles/cplusplus_tutorials/20060325/), but that
didn't really answer my question either.  If you throw an exception many
routine calls deep in the code does control immediately jump to the catch
block after the try block in the calling code or is all the intervening
function processing and returning involved (which would then necessarily
call exit)?

I guess from what you have said, the answer to that rhetorical question must
be "immediate jump", but there must be a very special mechanism to make the
code block code location available to _all_ code (no matter how many routine
calls are used to get to that code) which _might_ throw an exception.

I was well aware Python had exception handling, but I never thought too much
until now about the machine code practicalities involved in the code jump
involved (and skipping all intervening code) in transferring control in a
different way than the normal function return mechanism when an exception
has been thrown.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to