Would you find it useful?

... I've been thinking about this for a little while, but, would any of you
find it useful to have ruby be able to provide you with the source of a
function ...

I could see a number of uses. Including being able to modify the function at
run time, or to be able to see the parameter list ... or other things.

Anyways, I was thinking of something like:

func_body = Object.method( :to_s ).src

func_body.replace( "\* 3", "\* 4" )

Object.class_eval( func_body )

... what do you think?

j.

···

--
"http://ruby-lang.org -- do you ruby?"

Jeff Wood

Quoting Jeff Wood <jeff.darklight@gmail.com>:

... I've been thinking about this for a little while, but, would
any of you find it useful to have ruby be able to provide you with
the source of a function ...

... what do you think?

* What's the best way to treat methods not written in Ruby?

* Why not an abstract syntax tree rather than a flat string?

-mental

... I've been thinking about this for a little while, but, would any of you
find it useful to have ruby be able to provide you with the source of a
function ...

You already can do that with ruby2c and ZenHacks.

I could see a number of uses. Including being able to modify the function at
run time, or to be able to see the parameter list ... or other things.

Anyways, I was thinking of something like:

func_body = Object.method( :to_s ).src

func_body.replace( "\* 3", "\* 4" )

Object.class_eval( func_body )

... what do you think?

MetaRuby is rewriting Ruby in itself. When we're done you can get the source for Object#to_s, but we haven't gotten that far yet.

···

On Nov 1, 2005, at 1:16 PM, Jeff Wood wrote:

--
Eric Hodel - drbrain@segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

The Zen Spider has done some work on this :
http://blog.zenspider.com/archives/2005/02/rubytoruby.html.

You might find it interesting :wink:

Yep, that's the second link to the Zen stuff ...

I went and looked at things, looks like what I'm after ...

Thanks all.

j.

···

On 11/1/05, Eric Hodel <drbrain@segment7.net> wrote:

On Nov 1, 2005, at 1:16 PM, Jeff Wood wrote:

> ... I've been thinking about this for a little while, but, would
> any of you
> find it useful to have ruby be able to provide you with the source
> of a
> function ...

You already can do that with ruby2c and ZenHacks.

> I could see a number of uses. Including being able to modify the
> function at
> run time, or to be able to see the parameter list ... or other things.
>
> Anyways, I was thinking of something like:
>
> func_body = Object.method( :to_s ).src
>
> func_body.replace( "\* 3", "\* 4" )
>
> Object.class_eval( func_body )
>
> ... what do you think?

MetaRuby is rewriting Ruby in itself. When we're done you can get
the source for Object#to_s, but we haven't gotten that far yet.

--
Eric Hodel - drbrain@segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

--
"http://ruby-lang.org -- do you ruby?"

Jeff Wood

There's also SCRIPT_LINES__, which captures all your 'require' and
'load's in a hash (except for C modules):

http://redhanded.hobix.com/inspect/whoaScript_lines__.html

AegisThorne@gmail.com wrote:

···

The Zen Spider has done some work on this :
http://blog.zenspider.com/archives/2005/02/rubytoruby.html\.

You might find it interesting :wink: