Forum: Ruby-dev Proc#to_source, Method#to_source

Posted by mame (Yusuke Endoh) (Guest)
on 2012-11-20 15:01
(Received via mailing list)
Issue #2080 has been updated by mame (Yusuke Endoh).

Target version changed from 2.0.0 to next minor


----------------------------------------
Feature #2080: Proc#to_source, Method#to_source
https://bugs.ruby-lang.org/issues/2080#change-33313

Author: yugui (Yuki Sonoda)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: next minor


=begin
 [ruby-core:24673]に見るように、Proc#to_sourceやMethod#to_sourceがあると、1.8時代にnode.hを利用してしまっていたようなライブラリの問題の多くを解決できます。そこでnodeやiseqに元のソースコードを持たせておいて、必要に応じてiseqから取得することを提案します。

 一般的にはコードは処理データに比べて十分に小さいので、メモリ所要量の増加は許容範囲ではないでしょうか。

 例:
  proc = ->(x, y) {
    x + y
  }
  proc.to_source #=> "x + y"
=end
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.