From: Kaspar Schiess Date: 2005-02-28T20:12:03+09:00 Subject: Re: structuring complexly-interdependent C/Ruby libraries Hello Eric, Usually, you define classes in your C extension and likewise in your Ruby code, doing things twice, which does not matter since Ruby will take your meaning (creating one class). -- myclass.c Init_... { cMyClass = rb_define_class_under( mMyModule, "MyClass", rb_cObject ); } -- myclass.rb require 'myclass.so' class MyClass # ... end But yeah, redefinition with a different superclass gives you a SuperClassMismatch. So I would aim for different classes altogether, using mixins to mix the c code into the Ruby code: -- myclass.c Init_... { mMyClassMixin = rb_define_module_under( mMyModule, "MyClassCMixin" ); ... } -- myclass.rb require 'myclasscmixin' class MyClass < MySuperClass include MyClassCMixin #... end This method is tested and works, and it looks clean enough to me. Now does this solve all your problems ? Yes, if I read you right. k code manufacture & ruby lab at http://www.tua.ch/ruby -- The man who sets out to carry a cat by its tail learns something that will always be useful and which never will grow dim or doubtful. -- Mark Twain