Paul Brannan wrote: > 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. Ahh... that's what I didn't know. > > 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. I wish there was a scripting language that did just that... I am yearning for a scripting language that has support for C++ exceptions out-of-the-box... > > 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. I thought of that too. > > Paul > > > thanks for the reply. -- http://www.it-is-truth.org/