This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
scm_cur_loadp in an error hander
- To: guile at sourceware dot cygnus dot com
- Subject: scm_cur_loadp in an error hander
- From: Keisuke Nishida <kxn30 at po dot cwru dot edu>
- Date: 14 Mar 2000 19:27:45 -0500
Hello,
I would like to display some file information in my application
if an error occured during file loading. I used scm_internal_catch
and defined the error hander like this:
static SCM
error_handler (void *handler_data, SCM tag, SCM throw_args)
{
if (scm_cur_loadp != SCM_BOOL_F)
{
scm_port *port = SCM_PTAB_ENTRY (scm_cur_loadp);
printf ("%s:%d:%d: ",
SCM_CHARS (port->file_name),
port->line_number,
port->column_number);
}
...
}
This doesn't work. Whenever the handler is called, the value of
scm_cur_loadp is reset to SCM_BOOL_F (due to dynamic-wind ?).
I guess one way to do my task is:
1. Create a new variable scm_err_loadp.
2. Define scm_primitive_load so as to use scm_internal_catch
in addition to (or instead of) scm_internal_dynamic_wind.
3. Set scm_err_loadp to scm_cur_loadp in the hander before
reseting scm_cur_loadp to the previous value.
4. Refer to scm_err_loadp in my own hander.
I think, if it works, this is generally useful because people
(especially me) often make trivial mistakes in a file and want to
know where the error is.
Could this be implemented?
Thanks,
Keisuke Nishida