On Sep 1, 2006, at 12:23 AM, Jeremy Tregunna wrote:

> On 06-09-01, at 02:45, femto gary wrote:
>
>> hello all, Can I see method source code,
>> like in javascript, when you generate a function,
>> you can call to_string on it to see its source code.
>> It's especailly useful when you examine other's code
>> or dynamic generating func/method.
>
> No, there are only a few languages I can think of (okay, 2) that  
> allow this: the aforementioned javascript, and Io; Ruby does not.

Lies (provided the method is written in Ruby).

$ ruby -rlib/ruby2ruby.rb -I ../../ruby_to_c/dev/lib/ -e 'puts  
Object.source(:source)'
def source(method_name = nil)
   RubyToRuby.new.process(parse_tree(method_name))
end

You can find ruby2ruby.rb in the ZenHacks gem.

-- 
Eric Hodel - drbrain / segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com