From: Phlip Date: 2001-12-10T03:58:33+09:00 Subject: [ruby-talk:28036] Re: Boost.Ruby ? Bruce Ingalls wrote: > I'd be interested to see how the Boost.Python people pulled this off. > I see that you already noticed that name mangling is *not* portable > between brands of compilers. Perhaps Boost assumes a GCC compatible > compiler? Boost uses a subset of C++ reflection (C++ templates have compile-time reflection) to bind at compile time to functions with arbitrary parameter lists. Consider this: int foo (string kozmik, Bullfrog &aBullfrog); ... bind (foo); With the names changed because I'm too lazy to look them up, that's all there is to it. With a C style binder, you would need to bind to a function with a fixed signature: VALUE foo_wrapper (VALUE args[]) { int got = foo (to_string (args[0]), to_Bullfrog (args[1])); return to_value (got); } Boost metatemplates wrote foo_wrapper for you inside of 'bind'. They did it by expanding 'bind' into one of an infinity of recursive templates instances that, in turn, wrapped every argument. That's C++ reflection. The paucity of accurate technical details in my post reveals how totally everyone should check this out for themselves. I suspect Boost is in the process of productizing their metatemplate library outside of BPL, so this may mean that one could write BRL without much reinvention or code harvesting. But nobody needs to go above or below the level of C++ just to bind. Nobody needs to invent another language (SWIG) to declare the bindings, and nobody needs to un-mangle linker names. -- Phlip phlip_cpp@yahoo.com http://www.greencheese.org/ParodyMode -- DARE to resist drug-war profiteering --