octave-maintainers
[Top][All Lists]
Advanced

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

f77_exception_encountered


From: John W. Eaton
Subject: f77_exception_encountered
Date: Thu, 1 Apr 2004 17:24:59 -0600

On 31-Mar-2004, Paul Kienzle <address@hidden> wrote:

| I notice a lot of references to f77_exception_encountered followed by a
| call to the error handler in liboctave.
| 
|  From my reading of libcruft/misc/f77-fcn.h, these are all redundant 
| because
| they are handled by F77_XFCN.
| 
| Is there something I'm missing?

I think the only place that f77_exception_encountered can be set to a
nonzero value is in xstopx, which then calls
octave_jump_to_enclosing_context, which will put us at the location
marked by "==>" below (octave_set_current_context is a macro that
expands to either sigsetjmp or setjmp):

  #define F77_XFCN(f, F, args) \
    do \
      { \
        octave_jmp_buf saved_context; \
        f77_exception_encountered = 0; \
        octave_save_current_context ((char *) saved_context); \
        if (octave_set_current_context) \
          { \
    ==>     octave_restore_current_context ((char *) saved_context); \
            if (f77_exception_encountered) \
              F77_XFCN_ERROR (f, F); \
            else if (octave_allocation_error) \
              octave_throw_bad_alloc (); \
            else \
              octave_throw_interrupt_exception (); \
          } \
        else \
          { \
            octave_interrupt_immediately++; \
            F77_FUNC (f, F) args; \
            octave_interrupt_immediately--; \
            octave_restore_current_context ((char *) saved_context); \
          } \
      } \
    while (0)


Next, we check to see why we are inside this if block.  If it is
because an f77 exception has occurred (i.e., xstopx has been called)
then we print an error message and exit the if block (the
F77_XFCN_ERROR macro just prints a message).  So I think the
additional check of f77_exception_encountered after F77_XFCN is still
needed.

We could change F77_XFCN_ERROR or F77_XFCN to throw a C++ exception
here.  But if we do that, I think we will need to have a different way
of printing tracebacks.  For example, we will need to catch exceptions
everywhere we need to print traceback information.  At the same time,
we should rething the use of error_state and error(), so that error()
throws an exception instead of just printing a message and setting
error_state.  I'm in favor of making changes like this because it will
mean less code in user functions, and makes the C++ error() more like
the Octave scripting error() function, but it will be a significant
amount of work to make it all happen.

jwe



reply via email to

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