[Prev][Next][Index][Thread]
Re: Using old C++ libraries with Dylan
On Wednesday, September 12, 2001, at 07:00 pm, Mark Jordan wrote:
> Here's my problem. I like Dylan and want to use it,
> but I have a huge investment in C++ libraries that
> I want to retain.
Are you on PC or another platform? Fun-Dev and Gwydion Dylan have
different strengths in dealing with C code.
> My ideal solution would be to somehow be able to catch
> any exceptions thrown by the C++ code in Dylan, but I
> don't know if it's technically possible.
>
> Any suggestions as to what to do?
Assuming you have access to the code:
You could #define throw() to call a Dylan callback that would then
signal() the error to Dylan. This is probably best as it doesn't touch
the stack or put the C++ runtime into any strange state.
Or you can wrap the public API methods in try/catch blocks and call
Dylan in the catch() section. This could be scripted to make it bearable.
set_unexpected() could be used to add an unexpected exception handler
that again could get a Dylan callback to signal. This may require
modifying the function declarations to have empty exception
specifications, but again could be scripted. std::set_terminate() is
less useful as it means the C++ runtime is being shut down.
So basically some means of intercepting the exception and translating it
to a Dylan condition. But I don't know what the stack's like when an
exception is being handled and how this would affect Dylan or the GC.
- Rob.
Follow-Ups:
References: