guile-user
[Top][All Lists]
Advanced

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

Re: C++ and stack unwinding/destruction


From: David Fang
Subject: Re: C++ and stack unwinding/destruction
Date: Wed, 21 Mar 2007 18:11:05 -0500 (EST)

> > So this means I should be able to stop the dynwind from
> > plowing through any pure C++ function, in theory, right?
>
> Yes.
>
> > (I'm still itching to upgrade the libguile API for C++,
> > if I only had the time to futz with it...)
>
> IMHO this is possible only by wrapping libguile with
> a C++ library. And even in this case mixing the two
> dynwinds is troublesome. I am not a C++ programmer,
> but maybe using object functions to invoke the Guile/C
> API and wrapping them in scm_dynwind_begin/end...

Hi,
        One possible approach could be to wrap top-level Guile/C calls in
C++ to convert dynwind exceptions into C++ exceptions, but isolate C++
exceptions to prevent them from espacing to guile/C by "rethrow"-ing with
scm_error or equivalent.
        e.g.

SCM
my_cxx_function(SCM arg1) {
        try {
                // actual function body that is protected from dynwinding
                // through upon error via some handler...
        } catch (...) {
                // helpful dianostic
                scm_error_scm(...);
        }
}

It the idea sound? or just crazy?

Fang





reply via email to

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