evil.rb wants love
If you're interested in the internals of the interpreter, evil.rb can prove an excellent educational tool, since it allows you to peek into the object model, method dispatching...
In the past, some people have been using evil.rb to *2
- change the class of an object
- manipulate the inheritance chain for fun and profit
- grab instance variables or singleton methods
- swap objects (ever heard of Object#become?)
- change the self context of a Proc (the way 1.9's instance_exec does)
- mess with the flags of an object (frozen, tainted...)
Here's a list of articles where evil.rb is used to extend Ruby or illustrate how the interpreter works (please drop a comment if you have additional pointers of interest):
- Ruby code that will swallow your soul, a humorous introduction by Daniel Berger
- A taste of evil.rb: using DL to unfreeze objects
- Easy AOP right now using evil.rb thread on ruby-talk.
- Low-level introspection to save brain bits: Ruby object model, class hierarchy and method dispatching
- Tricking that old, picky interpreter: prototype-based OOP, and Prototype-based Ruby by Tomasz Węgrzanowski
evil.rb wants some love from people willing to add new features and/or maintain it. If you want to play with it and don't mind hacking code that is meant not to be used in production, feel free to contact Florian Groß (flgr at ccan.de) or me.
As per the discussion on oreillynet, it appears that Object#become was removed due to compatibility issues with 1.9. I'd like to see it added back for the 1.8.x users, with a big warning sticker for the 1.9 folks.
- 36 http://anarchaia.org
- 20 http://www.anarchaia.org
- 9 http://planetruby.0x42.net
- 7 http://www.artima.com/forums/flat.jsp?forum=123&thread=202258
- 6 http://anarchaia.org/archive/2007/04/12.html
- 3 http://www.feedphp.com/ruby
- 3 http://angg.twu.net/e/ruby.e.html
- 3 http://www.artima.com/buzz/index.jsp
- 2 http://www.rojo.com/feed/oh-mQT7JQdUD5Dzr
- 2 http://www.artima.com/buzz/index.jsp?start=15&thRange=15