This is a multi-part message in MIME format.
--------------070807040300090706010506
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Please consider the attached patch to
the eval.c supplied with Ruby 1.6.8.
This patch adds instance methods __file__ and __line__ to the
built-in classes Method and Proc. These methods are analogous
to the reserved words __FILE__ and __LINE__
The reserved words __FILE__ and __LINE__ cannot be used
to extract the source location of a previously parsed block of
ruby code, because the parser does a literal substitution of the String
or FixNum, respectively. So, at least in Ruby 1.6.8, Matz's suggested
technique of evaluating __FILE__ and __LINE__ in the binding
of the block does not work. Please see:
http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/21555
--------
Aside:
I'd be very interested in hearing about alternative approaches to this
problem. Has it already been addressed beta test versions of ruby?
Is there any reason why a similar approach shouldn't be taken for
later versions?
--------
On top of these methods for source reflection, I've written a simple
ruby class called SourceRef that manages "Source References". I've
attached sourceref.rb just as an example of what's possible and hopefully
to motivate folks to accept the patch because it's just plain useful and
doesn't impact performance or memory footprint.
I've also modified the rbbr package to display the source to ruby methods
instead of a useless (no document) message. And, I've added to rbbr
menu items to view, edit and reload the source file.
The combination of irb, rbbr, nedit (or some similar editor) and
my simple hacks actually become a lightweight, modular ruby IDE!
If this patch is approved -- or someone can show me how to write the
attached sourceref.rb without resorting to a patch to eval.c! -- I will
work with the owners of the irb and rbbr packages to incorporate
my (tiny) changes.
None of this is "rocket science", but I think it helps make Ruby
more accessible to a larger audience.
--
Brent Roman MBARI
Software Engineer Tel: (831) 775-1808
7700 Sandholdt Road, Moss Landing, CA 95039
mailto:brent / mbari.org http://www.mbari.org/~brent
--------------070807040300090706010506
Content-Type: text/plain;
name¥å¥¢¥ç¥«¥ç¥¯¥ç¡Ö
¥Æ¥å¥ä¥å¥Ê¥³ ¥
¥Æ¥å¥È¥³ ¥µ
¥å¥¢¥ç¥«¥ç¥¯¥ç¡Ö
¥å¥å¥å ¥ç ¥¤¡¼¡¼¥¦¥Ã¡¼¥¤¥Ã¥¢¥¢ ¥¤¡¼¥³¥ª¥«¥³¡¼¥¢ ¥¢¥ç¥¢
¥©¥©¥© ¥ç ¥¤¡¼¡¼¥¦¥Ã¡¼¥¤¥Ã¥¤¡¼ ¡¼¥¯¥³¥¤¥¢¥³¥¨¥¤ ¥¢¥ç¥¦
¥¿¥¿ ¥å¥¦¥ã¥ ¥©¥¦¥ã¥ ¥¿¥¿
¥ç ¥å
¡¢¥Á¥³ ¡¢
¥å ¡¢¥È¥³ ¥¤¡¼¡¼¥¦¥Ã¡¼¥¤¥Ã¥¢¥¢ ¥¤¡¼¥³¥ª¥«¥³¡¼¥¢ ¡¢
¥© ¡¢¥È¥³ ¥¤¡¼¡¼¥¦¥Ã¡¼¥¤¥Ã¥¤¡¼ ¡¼¥¯¥³¥¤¥¢¥³¥¨¥¤ ¡¢
¥³ ¥ä ¥Ï ¥¢¡¼ ¥¢¥¨¥³¥¤¥¤¥³¥¢¥ ¥Ï¥â¥ä ¥¢¥±¥±¥¦
¥Æ ¥£¥Æ¥¥ ¥¢¥±¥±¥¦¥å¥¤¡¼¡¼¥¢ ¥ë ¥Ø
¥¿¥¿ ¥å¥«¥±¥¥¢¥ã¥« ¥©¥«¥±¥¥¢¥ã¥ª¥¨ ¥¿¥¿
¥µ
¥©¥Ã¥§ ¥Û¥Ò¥³ ¥§¥Ã
¥©
¥© ¥è¥Á¥Õ¥æ¥Ê
¥©¡¬¡¬¡¬¥£¥è¥Á¥Õ¥æ¥Ê ¥¥
¥©
¥© ¥Ø¥Ê¥ä¥Í¥Þ¥È ¥§¥µ
¥© ¥§¥µ
¥©
¥© ¥È¡¬¥Ì¡¬¥â¥£¥ã ¥Ø¥Ê¥ä¥Í¥Þ¥È¥ã ¥¥¥µ
¥© ¥å¥»¥å¥»¡¬¥µ
¥© ¡¬¡¬¥¤¥£ ¥Û¥æ¥Õ¥Õ ¥½ ¡Ö¡Ö ¥³ ¥¥¥µ
¥©
¥©
¥© ¥è¥Á¥Õ¥æ¥Ê
¥©¡¬¡¬¥£¥è¥Á¥Õ¥æ¥Ê ¥¥
¥©
¥© ¥Ø¥Ê¥ä¥Í¥Þ¥È ¥§¥µ
¥©
¥© ¥È¡¬¥Ì¡¬¥â¥£¥ã ¥Ø¥Ê¥ä¥Í¥Þ¥È¥ã ¥¥¥µ
¥© ¥Î¥Û¥ä¥¤¥Ë¥Î¥ê¥£ ¡¬¥£¥å¥»¥¥ ¥¥¥µ
¥©
¥©
¥©¥Ã¥§ ¥Û¥Ò¥³ ¥§¥Ã
¥©
¥©¥Ã¥§ ¥Ä¥Á¥á¥³ ¥§¥Ã
¥©
¥© ¥è¥Á¥Õ¥æ¥Ê
¥©¡¬¡¬¡¬¥£¥è¥Á¥Õ¥æ¥Ê ¥¥
¥©
¥© ¥Ä¥Õ¥Þ¥Æ¥Ò ¥§¥µ
¥© ¥§¥µ
¥©
¥© ¥È¡¬¥Ì¡¬¥â¥£¥ã ¥Ä¥Õ¥Þ¥Æ¥Ò¥ã ¥¥¥µ
¥© ¥å¥»¥å¥»¡¬¥µ
¥© ¡¬¡¬¥¤¥£ ¥Û¥æ¥Õ¥Õ ¥½ ¡Ö¡Ö ¥³ ¥¥¥µ
¥©
¥©
¥© ¥è¥Á¥Õ¥æ¥Ê
¥©¡¬¡¬¥£¥è¥Á¥Õ¥æ¥Ê ¥¥
¥©
¥© ¥Ä¥Õ¥Þ¥Æ¥Ò ¥§¥µ
¥©
¥© ¥È¡¬¥Ì¡¬¥â¥£¥ã ¥Ä¥Õ¥Þ¥Æ¥Ò¥ã ¥¥¥µ
¥© ¥Î¥Û¥ä¥¤¥Ë¥Î¥ê¥£ ¡¬¥£¥å¥»¥¥ ¥¥¥µ
¥©
¥©
¥©¥Ã¥§ ¥Ä¥Á¥á¥³ ¥§¥Ã
¥©
¥Î¡¬¥ß¥£¥¥
¥¿¥¿ ¥å¥«¥±¥¯¥ª¥ã¥« ¥©¥¡¼¥¦¥¦¥ã¥¯ ¥¿¥¿
¡¬¡¬¥£¡¬¥ß¥ã ¡Ö¥í¥ó¡Ö¥ã ¡¬¥ã ¥å¥¤¥¥¥µ
¡¬¡¬¥£¡¬¥ß¥ã ¡Ö ¥ã ¡¬¥ã ¥¢¥¥¥µ
¡¬¡¬¥£¡¬¥ß¥ã ¡Ö¡¬¡Ö¥ã ¡¬¡¬¥ã ¡¼¥¥¥µ
¥© ¡¬¡¬¥£¡¬¥ß¥ã ¡Ö¡¬¡¬¡¬¡¬¡Ö¥ã ¡¬¡¬¡¬¥ã ¡¼¥¥¥µ ¥Ã¥§ ¥Ä¥Á¥á ¥§¥Ã
¥© ¡¬¡¬¥£¡¬¥ß¥ã ¡Ö¡¬¡¬¡¬¡¬¡Ö¥ã ¡¬¡¬¥ã ¡¼¥¥¥µ ¥Ã¥§ ¥Ä¥Á¥á ¥§¥Ã
¡¬¡¬¡¬¥£¡Ö¡Ö¥ã ¡¬¡¬¥ã ¡¼¥¥¥µ
¡¬¡¬¡¬¥£¡Ö¡Ö¥ã ¡¬¡¬¥ã ¡¼¥¥¥µ
¡¬¡¬¡¬¥£¡Ö¡Ö¥ã ¡¬¡¬¥ã ¡¼¥¥¥µ
¥¿¥¿ ¥å¥¡¼¡¼¥¤¥ã¥« ¥©¥¡¼¥ª¥¤¥ã¥¯ ¥¿¥¿
¡¬¡¬¥£¡¬¥Ø¥ã ¡Ö¡¬¡Ö¥ã ¡¬¥ã ¡¼¥¥¥µ
¡¬¡¬¥£¡¬¥Ø¥ã ¡Ö¡¬¡Ö¥ã ¡¬¥ã ¡¼¥¥¥µ
¡¬¡¬¥£¡¬¥Ø¥ã ¡Ö¡Ö¥ã ¡¬¥ã ¡¼¥¥¥µ
¥© ¡¬¡¬¥£¡¬¥Ø¥ã ¡Ö¡¬¡¬¡¬¡¬¡Ö¥ã ¡¬¡¬¡¬¥ã ¡¼¥¥¥µ ¥Ã¥§ ¥Û¥Ò ¥§¥Ã
¥© ¡¬¡¬¥£¡¬¥Ø¥ã ¡Ö¡¬¡¬¡¬¡¬¡Ö¥ã ¡¬¡¬¥ã ¡¼¥¥¥µ ¥Ã¥§ ¥Û¥Ò ¥§¥Ã
¡¬¡¬¥£¡¬¥Ò¥ã ¡Ö¡Ö¥ã ¡¬¡¬¥ã ¥¢¥¥¥µ
¡¬¥æ¥Ø ¡¬¡¬¥£¡Ö¥æ¥Ø¡Ö¥ã ¡¬¥Ø¥¥¥µ
¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¡¼¥¡¼¥¯¡¼¥¡¼¥¨¡¼¥¦¡¼¡¼¡¼¥±¡¼¥¡¼¥«¡¼¥¢¡¼¥ª¡¼¥«
¥Æ¥å¥ä¥³ ¥Ã¥µ
¥ç¡Ö
¥Æ¥å¥ä¥å¥Ê¥³ ¥
¥Æ¥å¥È¥³ ¥µ
¥ç¡Ö
¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡× ¥ç ¥å¥å ¥¿¥ç ¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×
¡× ¡¢¥â¥³ ¥Ã¥Ã¥Ã¥Ê¥â¥ß¥Ã¥¤¥Ã¥Ã¥Ã¥ç¥ã ¡¢
¡× ¡¢¥Î¥³ ¥ç¥ã ¥¢¥ç¥¢¥ª ¥¤¡¼¡¼¥¦¥Ã¡¼¥¤¥Ã¥¤¥¢ ¡¼¥¦¥³¥¦¥¯¥³¥¦¥¨ ¥Ê ¡¢
¡×
¡× ¥ä ¥â¥á ¥Ã¥ç
¡× ¡× ¥Ø
¡× ¥ß ¥ç ¥â¥á
¡× ¥³
¡×
¡× ¥ã
¡× ¥ã
¡×
¡×
¡×
¡× ¥ä ¥Þ ¥Ø ¥ã ¥ã
¡× ¥ã ¥ç
¡×
¡× ¥Ê¥³
¡× ¥â¥á¥ç¡¬ ¥£¥³¥¥¥ç ¥ç¥Ã¥ç¥³¥¨¥
¡× ¥â¥á¥ç¡¬ ¥£¥³¥¥¥ç
¡× ¥£¥â¥á¥Ã¥³¥¥¥ç
¡× ¥â¥á¥ç¥í¥³¥ó¥ç ¥Ã
¡× ¥È¥ç ¥È
¡× ¥È¥ç ¥È ¥â¥á
¡× ¥È¥ç¥ç ¥È ¥â¥á
¡× ¥È¥ç ¥È
¡× ¥È¥ç ¥£¥å¥¥ ¥È¥ç
¡×
¡× ¥é ¥ç ¥ã
¡× ¥³
¡×
¡× ¥Ø¥Ø¥Î¥â¥â
¡×
¡× ¥Ø ¥Ø
¡× ¥Ø ¥Ø
¡× ¥Î
¡× ¥â ¥³ ¥³
¡× ¥â ¥³ ¡Ö¡Ö
¡× ¡¼
¡×
¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×
¥â¥á ¡×
¥£¡¬¥ã
¥¿ ¡¬
¥¿
¡¬ ¥³¥ã ¥³
¡¬
¥» ¡¼
¥©¥¡¥³¥¡¥©¥ç¡¬
¡¬ ¥³¥ã ¥³¡¬
¡¬¥á
¥£¥Æ¥ã ¥Þ
¡× ¥Æ
¡× ¡Ö¡Ö
¡Ö¥µ
¥Ë¥ç ¥£¥¥
¥¤¥ç¥£¥©¥Þ¥¥ ¥ç¥µ ¥©
¥¢¥ç¥£¥Æ¥¥ ¥© ¥ç¥µ ¥©
¥Ê¥Þ¥Ë¥Ê ¡× ¥¡ ¥Ê¥Þ¥Ë ¡×
¥·
¡¢¡£¥ã¡Ö¥å¥å¥» ¥ä ¥³ ¡×¡Ö
¡¢¡£¥ã¡Ö¥å¥å¥» ¥Ø ¥³ ¡×¡Ö
¥£ ¥ã ù±¥¥
¡×
¡× ¥Î ¥ê¥å ¥ã ¥ã
¥Ê¥Û¥è¥í¡Ö¥È¥Î¥â¥ß¥Õ¥Á¥ë¡Ö¥ó
¥Á ¥å ¥á ¡× ¥¡¡×¥¡¡Ö
¥Á ¥å ¡× ¡Ö ¥© ¥Á ¥» ¡¼
¥Á ¥å ¡Ö ¥© ¥Á
¡× ¥Ã¥Ã¥Ã¥ê¥¢¥¢¥Ã
¥£¡Ö ¥å ¥å ¡×¥Á ¥¤¥»¥Ã¥Ã¡Ö¥¥
¥£¡Ö ¡×¥Á ¥ò¡Ö¥¥
¡× ¥ã ¥¡¥¡
¥£¡Ö ¡×¡Ö¥å¥á ¡Ö ¥© ¡×¡Ö¥¥
¥£ ¥¥
¡× ¥å
¥£¥ã ¥¥
¡×
¥Õ¥Ê
¡¢¡£¥ã ¡Ö¥å¥å¥» ¥Ø ¥³ ¡×¡Ö
¥â¥á¥ç¡¬¡¬¡¬ ¥£¥ã ¥¥
¡×
¡×
¥ß ¥ç¥£¥¡¥³¥¡¥ã¥¨¥¥¥í¥¤¥ó
¥ß¥ç¥£¥¡¥ï¥§¥¡¥ã ¥¤¥¥¥í¥¢¥ó¥í¥¢¥ç¥ç¥ç¥å¥¢¥ó
¥ç
¥â¥á¥ç¡¬¡¬ ¥£¥ã
¡×
¡×
¥Õ¥ç¡¬¥½¥£¥â¥¥ ¥½
¥â¥á¥ç¡¬¡¬¡¬ ¥£¥ã ¥¥ ¥³ ¥í¥ó
¥Õ
¥Î¥á¥Ä¥ã ¥Õ ¥Õ¥ç¥£¥¡ ¥¡¥ã ¥¦¥¥
¥Õ ¥Î¥á¥Ä ¥Î¥á¥Ä ¡Ö¡Ö
¥Õ¥ç¥£¥¡¥³¥¡¥ã¥¦¥¥¥í¡¼¥ç¥ç¥¢¥ó¥ç¥£¥¡¥³¥¡¥¥¥ç¡¬¥á
¥Æ ¡× ¡¬¡¬¡¬¡¬ ¥ò ¡¬¡¬¡¬¡¬
¥â¥á¥ç ¥£¡¬¡¬¡¬¡¬¥ã ¡¬¡¬¡¬¡¬¥¥
¡¬ ¥³¡¬¥á¥ã ¥³
¡× ¥¡ ¡¬ ¥¢¥ç¥« ¥â¥á¥³¥³¥Æ
¥£¥Þ¥ß¥â ¥³¥ã ¥³¥ã ¥³¥ã ¥³ ¥ó¥¥¥ç
¡Ö ¡×¥µ ¥ç¡×¥µ ¡Ö
¡× ¥â¥á¥³¥³¥Æ
¥Æ¥Ä ¡×
¥Æ¥³¥³¥Þ¥ß¥â¥ç
¡¬ ¥£¥¥ ¥§
¥ç ¥½ ¥Î¥á¥Ä¥ç¥í¥³¥ó ¥³ ¥ç
¡× ¥â¥á
¡×¥Ø ¥ç ¡¬ ¥ò ¥Î¥á¥Ä¥ç
¥ç¡¬¥½¥£¥Ø¥¥
¥ç¥ç ¥á ¥á¥ç¥£¥¥¥ç ¥£¥§¥¥
¥ç¡¬¥½¥£¥Î¥¥ ¥ç¡¬¥½¥£¥â¥¥
¡×
¥á¥ç¡¬¡¬¥£¥Î¥á¥Ä¥ç¥í¥³¥ó¥ç¥ã ¥¥
¥ç¡¬¥½ ¥³¡¬¥á
¥ç¡¬¥á¥ç¥£¥¥¥ç ¥£¥§¥¥
¡Ö¥Û ¡Ö¥ã¥ç¥ã¥¡¥³¥¡¥ã¥ç¥ã¡Ö¥ï¡Ö
¥á¥Ä¥Ä¥á ¡× ¥á ¥Æ ¥Ä
¥¡¥¡
¥£¥ä ¥ç ¥á¥Ä¥Ä¥á¥ç¥¥¥ç ¥ç¥ç¥©¥¢
¥ä
¡× ¥â¥á
¡×
¥ß¥µ ¥â¥á¥³¥³¥Æ¥µ
¥Ø¥µ ¥â¥á¥³¥³¥Æ¥µ
¥Þ¥µ ¥â¥á¥³¥³¥Æ¥Ä¥µ
¥â
¡× ¡£
¥Í
¥£ ¡Ö¥¥
¡× ¥ç
¥Á ¥ó
¥ã ¥Á ¥·¥· ¥ç¥©¥©¥ç¡¬
¥Á
¥â
¡¬¥á
¡× ¥³¡×
¡£
¥£¥¡¥³¥¡¥¥
¥â¥á¥ç ¥£¥ã ¡¼¥¥ ¥ç ¥· ¥¤
¥â¥á¥ç ¥£¥í¡¼¥ç¥ç¥å¥¤¥ó¥ç¥£¥¡¥³¥¡¥¥¥ã ¥í¥å¥¢¥ó¥ç¡¬¥¥
¥Ê
¡¬¥á ¥£
¡×
¥â¥á¥ç¡¬¡¬¥£¥ã ¥¥
¥â¥Ê ¥· ¥â¥Ê
¡× ¥È ¥â ¥á
¡¬¥á ¥£ ¥¥
¥ç¡¬¥á
¡¬¥ç¥£¡Ö¥ï¡Ö¥ã¥¤¥¥¥í¡¼¥ó¥ç¡¬¥á
¥Ø
¥Í ¥£¥ä¥ã ¥Û¥Á¥¥
¡× ¥Û ¥á
¡×
¥µ
¥Ì ¥£¥ä¥¥
¥Û¥Á¥ç
¥ç
¥Ì¥í¥ó¥ç
¥í¥ó ¥ç ¥» ¡¼ ¥ò¥ò ¥ç ¡£ ¥£¥¥¡Ö
¥³¥Í
¡¬
¡× ¥¡ ¥â¥á
¥Í ¥£¥³¥ã ¡¬¥¥
¡¬ ¥£¥Áù±¥¥
¡× ¥¡ ¥â¥á
¡×
¥Í ¥£¥³¡¬¥ã
¡¬¡¬¥©
¡¬¡¬¥£¥Á¥¥¥©
¡¬¡¬¥£¥Á¥¥¥¥
¥£¥§¥¥
¡× ¥¡ ¥â¥á
¡× ¡¬
¡¬¥ç¥£¡¬¥£¥§¥¥¥¥
¡¦ ¥£¡¬¥¥
¡× ¡¬
¡× ¥æ ¥Ã ¡¬
¡¬
¥Ã ¥£¡¬¥¥
¡× ¡¬
¡¬ ¡¬
¥Û¥Ê
¡¬
¥£¥§¥¥
¡× ¥¡
¥£¡¬¥ç¥©¡¬¥£¥§¥¥¥ç¥¥¥ç
¥ç
¥ç¥ç ¥â¥á¥ç¥£¥¥
¥£¥§¥¥
¡× ¥¡
¥£¥§¥¥¥ç ¥ç
¥£¥§¥¥
¡× ¥¡
¥£¥§¥¥¥ç¥Ë ¥Ë¥ç ¥£¥§¥¥
¥£¥§¥¥
¡× ¥å ¥¡
¥£¥§¥¥¥ç¥Ë ¥Ë¥ç ¥£¥§¥¥
¥£¥§¥¥
¡× ¥ç
¥ç¥Ë ¥© ¥Ë¥ç ¥£¥§¥¥
¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¥å¡¼¥¡¼¥¯¡¼¥¡¼¥¨¡¼¥¦¡¼¡¼¡¼¥±¡¼¥¡¼¥«¡¼¥¢¡¼¥ª¡¼¥«¥å¥å