A Comparison of Python and Ruby Extension Interfaces (Re: Comparison between Python and "Ruby")

Greg Ewing greg.ewing at compaq.com
Thu Nov 4 11:16:07 CET 1999


Fernando Pereira wrote:
> 
> What's the effect of this on portability? For instance, how are
> pointers to live objects from the C stack handled? As is well-known,
> this cannot be done portably.

It scans the whole C stack and marks anything that looks like
it might be a pointer to a Ruby object. It assumes that setjmp()
saves any registers that might contain such pointers. There are
a few special cases coded in. Porting to a new system might
require this piece of code to be adjusted, although it looks
to me like it should work under most sensible architectures.

Global variables in C extensions which contain Ruby pointers
have to be explicitly made known during initialisation.

> > * Ruby seems to be able to raise exceptions without
> > having to explicitly propagate them back out of routines,

> Same comment. There is no portable way of unwinding the C stack. What
> does that mean for Ruby's portability?

It uses setjmp/longjmp. Presumably these work correctly on
any system where they are implemented. Porting Ruby to a
system where they're not implemented could be difficult.

Greg




More information about the Python-list mailing list