From: Paul Brannan Date: 2003-11-27T06:21:54+09:00 Subject: Re: Ruby - C++ extension On Sun, Nov 23, 2003 at 05:44:39PM +0900, Elias Athanasopoulos wrote: > As far as C++ Type Casting is concerned I am thinking of creating > to_xxx methods. I.e. > > foo = (Foo *) Bar->dump(); This is not C++ type casting; this is a C-style cast. In C++, you generally want to avoid C-style casts because C-style casts are far too powerful (they let you lie to the compiler far too easily). Please consider using static_cast<> and dynamic_cast<> whenever possible. > will be in Ruby: > > foo = Bar.dump.as_Foo I'm not sure this really applies well to Ruby. Because Ruby is dynamically typed, there's no reason why dump() can't just return an object of the appropriate type (e.g. return a Foo if you really have a Foo or return a Bar if you really have a Bar). > As far as Multiple Inheritence is concerned, I think the only way > to go through is to define modules and include them in other modules. > Howver the C++ project I'm trying to create Ruby Bindings for, has a very > complex inheritence tree. Is there any other workaround? Yes, modules are the way to go. See [ruby-talk:66580] and my suggestion in [ruby-talk:66624]. Paul