Feature #3424: Source code interaction. [new ideas for ruby 2]
http://redmine.ruby-lang.org/issues/show/3424

Author: Eloy Esp
Status: Open, Priority: Low
Category: core

I have some ideas that I think can do Ruby even better, but I cannot implement those, because I'm not C programer and I cannot do it. (sorry about that).

Resumed: In general my idea is to implement some methods in Ruby core to interact with the source code.
This could enhance irb, and could develop the idea of *interactive programing*, which means you would write your programs interacting with it.

Some things I would like to see in ruby:
---------------------------------------
Ruby is an scripting language, meaning it does not compile to work, then there are certain things that are possible, like irb, this is, you can write ruby in a console like sistem. This is good, but could be better.

First idea: Source integration with ruby.

supose I wrote:

# dog.rb
class Dog
  # Make the dog happy
  def bark
    puts "Dog is barking"
  end
end

Now, what I do to read about the class Dog? I have to open dog.rb in a text editor. But ruby is reading the source. There could be a method in the class Dog (in Object I thing) that give me access to the source code, something like:

# reading.rb
puts Dog.source
=> "def bark ; puts "Dog is barking" ; end"

Think about using this in IRB in a rails proyect, where the classes are defined in 30 files or more, and you have to look through files that ruby have read, know perfectly when a method has been re-defined, etc.

It don't look like usefull? Then I can think some more usefullness...

Second: Rdoc integration

# help.rb
Dog.method(:bark).RDoc
=> "Make the dog barking"

We have to remember that the source code is right there, it has not been compiled and probably never will, so are the comments.

---
Thanks for reading, and sorry if it is not the place, feel free to correct or delete this message.

El_Hoy

postscript: I think ruby could be the next standard shell and in this way is my mind thinking to improve irb. Also I thinking that the idea of interactive programing could become realy interesting.


----------------------------------------
http://redmine.ruby-lang.org