Module.new

e$B$o$?$J$Y$G$9!#e(B

1.9e$B$Ne(BModule.newe$B$N%V%m%C%/0z?t$,$J$<$+e(Bnile$B$K$J$C$F$7$^$$$^$9!#e(B

% ruby-1.9 -e ‘Module.new{|mod| p mod}’
nil

e$B$=$l$O$=$l$H$7$F!"e(Bmake
minirubye$B$@$1$G$J$/>/$J$/$H$be(Bmakee$B$G$-e(B
e$B$F$+$i%3%_%C%H$7$F$/$@$5$$!#e(B

e$B$J$+$@$G$9!#e(B

At Thu, 5 Oct 2006 18:09:18 +0900,
WATANABE Hirofumi wrote in [ruby-dev:29637]:

1.9e$B$Ne(BModule.newe$B$N%V%m%C%/0z?t$,$J$<$+e(Bnile$B$K$J$C$F$7$^$$$^$9!#e(B

% ruby-1.9 -e ‘Module.new{|mod| p mod}’
nil

e$B$3$C$A$O$^$@$h$/8+$F$J$$$s$G$9$,e(B

e$B$=$l$O$=$l$H$7$F!"e(Bmake minirubye$B$@$1$G$J$/>/$J$/$H$be(Bmakee$B$G$-e(B
e$B$F$+$i%3%_%C%H$7$F$/$@$5$$!#e(B

e$B$3$C$A$O$3$s$J$H$3$G$7$g$&$+!#e(B

Index: parse.y

RCS file: /pub/cvs/ruby/src/ruby/parse.y,v
retrieving revision 1.464
diff -U 2 -p -u -r1.464 parse.y
— parse.y 4 Oct 2006 07:17:16 -0000 1.464
+++ parse.y 5 Oct 2006 15:52:43 -0000
@@ -541,5 +541,5 @@ static void ripper_compile_error(struct
%type assoc_list assocs assoc undef_list backref string_dvar
%type for_var block_param opt_block_param block_param_def
block_param0
-%type block_param1 bparam_post
+%type block_param1 bparam_post block_mparam0 block_mparam
%type opt_bv_decl bv_decls bv_decl lambda f_larglist lambda_body
%type brace_block cmd_brace_block do_block lhs none fitem
@@ -2859,8 +2859,8 @@ for_var : lhs

block_param1 : bv_decl

  •   | tLPAREN block_param rparen
    
  •   | tLPAREN block_mparam rparen
          {
          /*%%%*/
    
  •   	$$ = NEW_MASGN(NEW_LIST($2), 0);
    
  •   	$$ = $2;
          /*%
      	$$ = dispatch1(mlhs_paren, $2);
    

@@ -2909,16 +2909,36 @@ block_param : block_param0
{
/%%%/

  •                    if ($1->nd_alen == 1) {
    
  •                        $$ = $1->nd_head;
    
  •                        rb_gc_force_recycle((VALUE)$1);
    
  •                    }
    
  •                    else {
    
  •                        $$ = NEW_MASGN($1, 0);
    
  •                    }
    
  •   	if ($1->nd_alen == 1) {
    
  •   	    $$ = $1->nd_head;
    
  •   	    rb_gc_force_recycle((VALUE)$1);
    
  •   	}
    
  •   	else {
    
  •   	    $$ = NEW_MASGN($1, 0);
    
  •   	}
    
  •       /*%
    
  •   	$$ = blockvar_new($1);
    
  •       %*/
    
  •       }
    
  •   | block_mparam0
    
  •       {
    
  •   	$$ = $1;
    
  •       }
    
  •   ;
    

+block_mparam : block_param0

  •       {
    
  •       /*%%%*/
    
  •   	$$ = NEW_MASGN($1, 0);
          /*%
      	$$ = blockvar_new($1);
          %*/
          }
    
  •   | block_param0 ','
    
  •   | block_mparam0
    
  •       {
    
  •   	$$ = $1;
    
  •       }
    
  •   ;
    

+block_mparam0 : block_param0 ‘,’
{
/%%%/

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:29637] Module.new”
on Thu, 5 Oct 2006 18:09:18 +0900, WATANABE Hirofumi
[email protected] writes:

|e$B$=$l$O$=$l$H$7$F!"e(Bmake minirubye$B$@$1$G$J$/>/$J$/$H$be(Bmakee$B$G$-e(B
|e$B$F$+$i%3%_%C%H$7$F$/$@$5$$!#e(B

e$B$^$?$d$C$A$c$$$^$7$?!#:#8e5$$r$D$1$^$9!#e(B

e$B$J$+$@$G$9!#e(B

At Thu, 5 Oct 2006 18:09:18 +0900,
WATANABE Hirofumi wrote in [ruby-dev:29637]:

1.9e$B$Ne(BModule.newe$B$N%V%m%C%/0z?t$,$J$<$+e(Bnile$B$K$J$C$F$7$^$$$^$9!#e(B

% ruby-1.9 -e ‘Module.new{|mod| p mod}’
nil

module_exece$B$r;H$&I,MW$,$"$k$h$&$G$9!#e(B

Index: object.c

RCS file: /cvs/ruby/src/ruby/object.c,v
retrieving revision 1.203
diff -p -U 2 -r1.203 object.c
— object.c 22 Sep 2006 08:36:02 -0000 1.203
+++ object.c 5 Oct 2006 21:08:39 -0000
@@ -1206,5 +1206,5 @@ rb_mod_initialize(VALUE module)
{
if (rb_block_given_p()) {

  • rb_mod_module_eval(0, 0, module);
  • rb_mod_module_exec(1, &module, module);
    }
    return Qnil;

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:29639] Re: Module.new”
on Fri, 6 Oct 2006 06:10:41 +0900, Nobuyoshi N.
[email protected] writes:

|At Thu, 5 Oct 2006 18:09:18 +0900,
|WATANABE Hirofumi wrote in [ruby-dev:29637]:
|> 1.9e$B$Ne(BModule.newe$B$N%V%m%C%/0z?t$,$J$<$+e(Bnile$B$K$J$C$F$7$^$$$^$9!#e(B
|>
|> % ruby-1.9 -e ‘Module.new{|mod| p mod}’
|> nil
|
|module_exece$B$r;H$&I,MW$,$"$k$h$&$G$9!#e(B

e$B%3%_%C%H$7$F$/$@$5$$!#e(B