--Multipart_Mon_Feb_16_12:43:38_1998-1
Content-Type: text/plain; charset=ISO-2022-JP

Á°ÅĤǤ¹¡£

In message "[ruby-list:6423] Re: rgrep (Re: call for scripts)"
Yukihiro Matsumoto <matz / netlab.co.jp> wrote:

|¥¤¥Æ¥ì¡¼¥¿¥Ö¥í¥Ã¥¯¤ò¤Þ¤Þ°ú¤­ÅϤ¹
|
|  {|x| yield x}
|
|¤ÎÂå¤ï¤ê¤Ë¤Ê¤ëµ­¹æ¤¬¤¢¤ì¤ÐÎɤ¤¤Î¤À¤í¤¦¤È»×¤¦¤Î¤Ç¤¹¤¬¡¤¤Ê¤«¤Ê
|¤«Îɤ¤¤Î¤¬»×¤¤ÉÕ¤­¤Þ¤»¤ó¡¥
|
|  foreach_files(path) xxx
|
|¤Îxxx¤ÎÉôʬ¤ËÍè¤ë¤¤¤«¤Ë¤â¤é¤·¤¤¤â¤Î(è¤ì¤Ð͸ì¤Ç¤Ê¤¤
|Êý¤¬Ë¾¤Þ¤·¤¤¤¬¡¤¸ì¤Ç¤âÎɤ¤)¤¬¡¤¤¢¤ì¤ÐÎɤ¤¤Î¤Ç¤¹¤¬¡Ä¡¥

¤Ê¤«¤Ê¤«Îɤ¤µ­¹æ¤ä̾Á°¤Ï¤Ê¤µ¤Ç¤¹¤Í¡£

ʸˡ³ÈÄ¥¤Ï¤»¤º¤Ë¡¢

obj.pass_block(:itername, args...)

¤È¤¤¤¦¥á¥É¤òÍѰդ¹¤ë¡¢¤È¤¤¤¦¤Î¤Ï¤É¤¦¤Ç¤·¤ç¤¦¡£


--Multipart_Mon_Feb_16_12:43:38_1998-1
Content-Type: application/octet-stream; type=patch
Content-Disposition: attachment; filename="eval.c.diff"
Content-Transfer-Encoding: 7bit

--- eval.c.orig	Mon Feb 16 12:18:24 1998
+++ eval.c	Mon Feb 16 12:29:27 1998
@@ -3396,6 +3396,35 @@
     return vid;
 }
 
+static VALUE
+f_pass_block(argc, argv, recv)
+    int argc;
+    VALUE *argv;
+    VALUE recv;
+{
+    VALUE vid;
+    ID mid;
+
+    if (argc 0) ArgError("no iterator name given");
+    if (iterator_p())
+	ArgError("iterator block given to pass_block");
+    if (!f_iterator_p())
+	ArgError("pass_block called out of iterator");
+
+    vid  rgv[0]; argc--; argv++;
+    if (TYPE(vid) T_STRING) {
+	mid  b_intern(RSTRING(vid)->ptr);
+    }
+    else {
+	mid  UM2INT(vid);
+    }
+    PUSH_ITER(ITER_PRE);
+    vid  b_call(CLASS_OF(recv), recv, mid, argc, argv, 1);
+    POP_ITER();
+
+    return vid;
+}
+
 #include <varargs.h>
 
 VALUE
@@ -4248,6 +4277,7 @@
     rb_define_global_function("global_variables", f_global_variables, 0);
 
     rb_define_method(mKernel, "send", f_send, -1);
+    rb_define_method(mKernel, "pass_block", f_pass_block, -1);
     rb_define_method(mKernel, "instance_eval", obj_instance_eval, 1);
 
     rb_define_private_method(cModule, "append_features", mod_append_features, 1);

--Multipart_Mon_Feb_16_12:43:38_1998-1
Content-Type: text/plain; charset=ISO-2022-JP


-- 
Á°ÅÄ ¨Â

­­ÍõìôéðáòôßÍïî߯åâß±¶ß±²º´³º³¸ß±¹¹¸­±­­