# RbDynamicMethod first drop

**URL:** <https://www.ruby-forum.com/t/rbdynamicmethod-first-drop/49643>\
**Category:** Ruby\
**Created:** [December 7, 2005, 6:06am UTC](https://www.ruby-forum.com/t/rbdynamicmethod-first-drop/49643 "2005-12-07T06:06:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![drjflam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ce7236/32.png) [@drjflam](https://www.ruby-forum.com/u/drjflam)\
**Post date:** [December 7, 2005, 6:06am UTC](https://www.ruby-forum.com/t/rbdynamicmethod-first-drop/49643/1 "2005-12-07T06:06:14Z")

</div>

I just posted a drop of RbDynamicMethod here:  
[http://www.iunknown.com/articles/2005/12/06/first-drop-of-rbdynamicmethod](http://www.iunknown.com/articles/2005/12/06/first-drop-of-rbdynamicmethod)

You’ll need a copy of Visual C++ 2005 (probably any edition, but I  
haven’t  
tried it on anything other than the Team Edition for Software  
Developers) to  
compile the sources. I understand that cl.exe (and hopefully its friends  
link.exe and mt.exe) ships with the WinFX SDK for those of you who don’t  
have a copy of Visual Studio 2005. I’ve provided a Rakefile, so you  
don’t  
need the IDE, just the compiler + linker + manifest tool.

Here’s a taste of the syntax in this example that maps CLR exceptions to  
Ruby exceptions:

create\_ruby\_method(‘convert\_clr\_exception’) do  
try  
ldstr ‘error’  
newobj ‘Exception.ctor(String)’  
throw\_ex  
catch\_ex ‘Exception’  
call ‘static ExceptionHelper.RaiseRubyException(Exception)’  
end\_try  
ldc\_i4\_4  
ret  
end

It’s about 330 lines of C++ and 100 lines of Ruby code.

Comments and suggestions would be _greatly_ appreciated!

Thanks,  
-John

> **[John Lam's Blog](https://www.iunknown.com/)**
>
> Since 1997
