This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Catching errors from scm_run_hook
Mikael Djurfeldt <mdj@mdj-pc.nada.kth.se> writes:
> Greg Badros <gjb@cs.washington.edu> writes:
>
> > Mikael Djurfeldt <mdj@mdj-pc.nada.kth.se> writes:
> >
> > > Greg Badros <gjb@cs.washington.edu> writes:
> > >
> > > > What is the right, supported way to catch errors when invoking
> > > > scm_run_hook?
> > >
> > > The right thing would be to use scm_internal_catch. Is that too
> > > complicated?
> >
> > Maybe not, if it were well documented. But, I think it's almost always
> > the case that the user will want to run hooks catching errors, so that
> > common case should have a simpler facility.
>
> I think you should include such a facility in SCWM. If enough
> application writers require such a facility, we'll include it in a
> later release.
We do:
__inline__ SCM scwm_run_hook(SCM hook, SCM args)
{
return scwm_safe_apply(run_hook_proc, gh_cons(hook,args));
}
which uses:
SCM
scwm_safe_apply (SCM proc, SCM args)
{
SCM_STACKITEM stack_item;
struct scwm_body_apply_data apply_data;
apply_data.proc = proc;
apply_data.args = args;
return scm_internal_stack_cwdr(scwm_body_apply, &apply_data,
scwm_handle_error, "scwm",
&stack_item);
}
which in turn uses:
SCM
scm_internal_stack_cwdr (scm_catch_body_t body,
void *body_data,
scm_catch_handler_t handler,
void *handler_data,
SCM_STACKITEM *stack_item)
{
struct cwssdr_data d;
d.tag = SCM_BOOL_T;
d.body = body;
d.data = body_data;
d.handler = handler;
return scm_internal_cwdr_no_unwind (cwssdr_body, &d, handler, handler_data,
stack_item);
}
which seems pretty complicated for this simple desire. I believe Maciej
wanted to use a new dynamic root to avoid misusing continuations.
Comments? If all this machinery is really necessary, then it's way too
hard for the application programmer to get right.
Thanks,
Greg