Daniel Berger
6/19/2007 5:38:00 PM
On Jun 19, 11:13 am, MenTaLguY <men...@rydia.net> wrote:
> Incidentally, I did want to throw in a note to be very, very careful about exceptions when wrapping C++ code as a Ruby extension.
>
> It's necessary to catch and wrap/unwrap exceptions at all C++/C boundaries, since otherwise, Ruby cleanup (ensure, rescue, etc...) will be skipped when C++ exceptions unwind the stack (potentially trashing the interpreter), and C++ cleanup (destructors for objects in automatic storage, catch, etc...) will get skipped when Ruby exceptions unwind the stack.
>
> Also, on some architectures, a C++ exception tearing down a C stack frame is by itself enough to cause badness.
>
> boost.python takes care of all this for writing Python extensions in C++, but sadly there's not a maintained Ruby equivalent.
>
> -mental
Maybe we should just rewrite the interpreter in C++ then. Think of all
the STL and Boost stuff we could then integrate "for free". I can only
guess what other advantages this might bring in the long run.
I know Matz has said in the past that the C++ object model would get
in the way, but I'm convinced it could be done (by smarter minds than
I).
Dan