From: Paul Brannan Date: 2004-07-27T21:42:06+09:00 Subject: Re: Anyone tried compiling Ruby with c++? On Tue, Jul 27, 2004 at 08:00:34PM +0900, Asfand Yar Qazi wrote: > No, I didn't say "porting Ruby to C++", I said "compiling Ruby > with C++." > > I think this would solve the problem of longjmping out of C++ > functions (due to throwing Ruby exceptions) and not having > destructors of stack objects declared in those C++ functions. Or > am I wrong? Unless I misunderstand you: the longjmp function is part of the C++ standard (since the C++ standard library includes the C89 standard library). Recompiling Ruby with a C++ compiler will not eliminate the calls to longjmp. The C++ standard is very clear that any call to longjmp that jumps over the desctruction of an automatic object will result in undefined behavior, irrespective of whether that code was compiled with a C or a C++ compiler. It would be possible to modify Ruby to use C++ exceptions, but this would not be a small change (Ruby wraps calls to longjmp in macros, but it's not just a matter of changing the macros, since longjmp and exceptions use a different syntax), and I don't know how well C++ exceptions would play with Ruby's threads. Also, C++ has much stricter typing than C, and I suspect that much of the Ruby source would fail to compiler under a C++ compiler without modification. Paul