[#23480] [BUG] numeric.c (flo_to_s) broken? — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>

山本です。

19 messages 2004/05/08
[#23482] Re: [BUG] numeric.c (flo_to_s) broken? — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2004/05/08

山本です。

[#23483] Re: [BUG] numeric.c (flo_to_s) broken? — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2004/05/08

山本です。

[#23484] Re: [BUG] numeric.c (flo_to_s) broken? — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2004/05/08

山本です。

[#23485] Re: [BUG] numeric.c (flo_to_s) broken? — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2004/05/08

山本です。たびたびすみません。

[#23486] Re: [BUG] numeric.c (flo_to_s) broken? — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2004/05/08

山本です。

[#23499] Re: [BUG] numeric.c (flo_to_s) broken? — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2004/05/14

山本です。

[#23488] Re: [ruby-cvs] ruby, ruby/ext, ruby/lib, ruby/lib/test/unit/ui/console, ruby/test, ruby/test/drb, ruby/test/ruby, ruby/test/soap/calc: * ext/extmk.rb (extmake): skip uncompiled extensions. — MIYAMUKO Katsuyuki <k-miyamuko@...>

みやむこです。

18 messages 2004/05/11
[#23527] Re: [ruby-cvs] ruby, ruby/ext, ruby/lib, ruby/lib/test/unit/ui/console,ruby/test, ruby/test/drb, ruby/test/ruby, ruby/test/soap/calc: * ext/extmk.rb(extmake): skip uncompiled extensions. — nobu.nakada@... 2004/05/17

なかだです。

[#23537] Re: [ruby-cvs] ruby, ruby/ext, ruby/lib, ruby/lib/test/unit/ui/console,ruby/test, ruby/test/drb, ruby/test/ruby, ruby/test/soap/calc: * ext/extmk.rb(extmake): skip uncompiled extensions. — MIYAMUKO Katsuyuki <k-miyamuko@...> 2004/05/18

みやむこです。

[#23538] Re: [ruby-cvs] ruby, ruby/ext, ruby/lib, ruby/lib/test/unit/ui/console,ruby/test,ruby/test/drb, ruby/test/ruby, ruby/test/soap/calc: * ext/extmk.rb(extmake):skip uncompiled extensions. — nobu.nakada@... 2004/05/19

なかだです。

[#23539] Re: [ruby-cvs] ruby, ruby/ext, ruby/lib, ruby/lib/test/unit/ui/console,ruby/test,ruby/test/drb, ruby/test/ruby, ruby/test/soap/calc: * ext/extmk.rb(extmake):skip uncompiled extensions. — MIYAMUKO Katsuyuki <k-miyamuko@...> 2004/05/19

みやむこです。

[#23543] Re: [ruby-cvs] ruby, ruby/ext, ruby/lib, ruby/lib/test/unit/ui/console,ruby/test,ruby/test/drb,ruby/test/ruby, ruby/test/soap/calc: * ext/extmk.rb(extmake):skip uncompiledextensions. — nobu.nakada@... 2004/05/19

なかだです。

[#23555] Re: [ruby-cvs] ruby, ruby/ext, ruby/lib, ruby/lib/test/unit/ui/console,ruby/test,ruby/test/drb,ruby/test/ruby, ruby/test/soap/calc: * ext/extmk.rb(extmake):skip uncompiledextensions. — MIYAMUKO Katsuyuki <k-miyamuko@...> 2004/05/21

みやむこです。

[#23557] Re: [ruby-cvs] ruby, ruby/ext, ruby/lib, ruby/lib/test/unit/ui/console,ruby/test,ruby/test/drb,ruby/test/ruby,ruby/test/soap/calc: * ext/extmk.rb(extmake):skip uncompiledextensions. — nobu.nakada@... 2004/05/21

なかだです。

[#23559] Re: [ruby-cvs] ruby, ruby/ext, ruby/lib, ruby/lib/test/unit/ui/console,ruby/test,ruby/test/drb,ruby/test/ruby,ruby/test/soap/calc: * ext/extmk.rb(extmake):skip uncompiledextensions. — MIYAMUKO Katsuyuki <k-miyamuko@...> 2004/05/21

みやむこです。

[#23492] ruby 1.8.1 (2004-05-13) has 7 failures and 3 errors — akira yamada <akira@...>

19 messages 2004/05/13

[#23533] Ruby2.0 spec summary around parameters and variables — SASADA Koichi <ko1@...>

 ささだです。

22 messages 2004/05/17
[#23563] Re: Ruby2.0 spec summary around parameters and variables — Minero Aoki <aamine@...> 2004/05/22

青木です。

[#23564] Re: Ruby2.0 spec summary around parameters and variables — matz@... (Yukihiro Matsumoto) 2004/05/22

まつもと ゆきひろです

[#23568] Re: Ruby2.0 spec summary around parameters and variables — Minero Aoki <aamine@...> 2004/05/22

青木です。

[#23569] Re: Ruby2.0 spec summary around parameters and variables — matz@... (Yukihiro Matsumoto) 2004/05/22

まつもと ゆきひろです

[#23572] keyword argments (Ruby2.0 spec) — Hidetoshi NAGAI <nagai@...>

永井@知能.九工大です.

14 messages 2004/05/23
[#23578] Re: keyword argments (Ruby2.0 spec) — matz@... (Yukihiro Matsumoto) 2004/05/23

まつもと ゆきひろです

[#23615] console freezed on test/drb/drbtest.rb : test_06_timeout (bcc32) — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>

山本です。

11 messages 2004/05/25
[#23625] Re: console freezed on test/drb/drbtest.rb : test_06_timeout (bcc32) — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2004/05/26

山本です。

[ruby-dev:23605] Re: Ruby2.0 spec summary around parameters and variables

From: nobu.nakada@...
Date: 2004-05-24 23:33:23 UTC
List: ruby-dev #23605
なかだです。

At Sun, 23 May 2004 23:45:43 +0900,
Yukihiro Matsumoto wrote in [ruby-dev:23581]:
> |> あとは、ブロックの中でyieldした場合、暗黙のブロック(yieldの
> |> 対象)は外側のものを継承する必要がありそうです。関数(or メソッ
> |> ド)と考えるとちょっと気持ちが悪いのですが。
> |
> |ええと、こういう話ですか。
> |
> |  def m1
> |    lambda {
> |      yield
> |    }
> |  end
> |  block = m1 { p "method" }
> |  block.call { p "call" }   #=> "method"
> |
> |
> |  def m2
> |    lambda {|&b|
> |      yield
> |    }
> |  end
> |  block = m2 { p "method" }
> |  block.call { p "call" }   # これが "call" でなく "method" になる、ということ?
> 
> そゆことです。m2のyieldがb.callであれば"call"になります。
> この方がわかりやすそうな気がするんですが、どうでしょう。

大体このシンタックスで行けそうでしょうか。


Index: eval.c
===================================================================
RCS file: /cvs/ruby/src/ruby/eval.c,v
retrieving revision 1.664
diff -U2 -p -d -r1.664 eval.c
--- eval.c	18 May 2004 00:32:30 -0000	1.664
+++ eval.c	24 May 2004 23:30:09 -0000
@@ -4570,5 +4570,5 @@ rb_yield_0(val, self, klass, flags, aval
     int flags, avalue;
 {
-    NODE *node;
+    NODE *node, *var;
     volatile VALUE result = Qnil;
     volatile VALUE old_cref;
@@ -4613,9 +4613,12 @@ rb_yield_0(val, self, klass, flags, aval
     }
     node = block->body;
+    var = block->var;
 
-    if (block->var) {
+    if (var) {
 	PUSH_TAG(PROT_NONE);
 	if ((state = EXEC_TAG()) == 0) {
-	    if (block->var == (NODE*)1) { /* no parameter || */
+	    NODE *bvar = NULL;
+	  block_var:
+	    if (var == (NODE*)1) { /* no parameter || */
 		if (lambda && RARRAY(val)->len != 0) {
 		    rb_raise(rb_eArgError, "wrong number of arguments (%ld for 0)",
@@ -4623,5 +4626,5 @@ rb_yield_0(val, self, klass, flags, aval
 		}
 	    }
-	    else if (block->var == (NODE*)2) {
+	    else if (var == (NODE*)2) {
 		if (TYPE(val) == T_ARRAY && RARRAY(val)->len != 0) {
 		    rb_raise(rb_eArgError, "wrong number of arguments (%ld for 0)",
@@ -4629,9 +4632,14 @@ rb_yield_0(val, self, klass, flags, aval
 		}
 	    }
-	    else if (nd_type(block->var) == NODE_MASGN) {
+	    else if (!bvar && nd_type(var) == NODE_BLOCK_PASS) {
+		bvar = var->nd_body;
+		var = var->nd_args;
+		goto block_var;
+	    }
+	    else if (nd_type(var) == NODE_MASGN) {
 		if (!avalue) {
-		    val = svalue_to_mrhs(val, block->var->nd_head);
+		    val = svalue_to_mrhs(val, var->nd_head);
 		}
-		massign(self, block->var, val, lambda);
+		massign(self, var, val, lambda);
 	    }
 	    else {
@@ -4654,5 +4662,5 @@ rb_yield_0(val, self, klass, flags, aval
 		  multi_values:
 		    {
-			ruby_current_node = block->var;
+			ruby_current_node = var;
 			rb_warn("multiple values for a block parameter (%d for 1)\n\tfrom %s:%d",
 				len, cnode->nd_file, nd_line(cnode));
@@ -4660,5 +4668,13 @@ rb_yield_0(val, self, klass, flags, aval
 		    }
 		}
-		assign(self, block->var, val, lambda);
+		assign(self, var, val, lambda);
+	    }
+	    if (bvar) {
+		VALUE blk;
+		if (flags & YIELD_PROC_CALL)
+		    blk = block->block_obj;
+		else
+		    blk = rb_block_proc();
+		assign(self, bvar, blk, 0);
 	    }
 	}
@@ -8022,11 +8038,10 @@ proc_invoke(proc, args, self, klass)
     struct RVarmap * volatile old_dvars = ruby_dyna_vars;
     volatile int pcall, avalue = Qtrue;
+    VALUE bvar = Qnil;
 
     if (rb_block_given_p() && ruby_frame->last_func) {
 	if (klass != ruby_frame->last_class)
 	    klass = rb_obj_class(proc);
-	rb_warning("block for %s#%s is useless",
-		   rb_class2name(klass),
-		   rb_id2name(ruby_frame->last_func));
+	bvar = rb_block_proc();
     }
 
@@ -8044,4 +8059,5 @@ proc_invoke(proc, args, self, klass)
     old_block = ruby_block;
     _block = *data;
+    _block.block_obj = bvar;
     if (self != Qundef) _block.frame.self = self;
     if (klass) _block.frame.last_class = klass;
@@ -8054,5 +8070,6 @@ proc_invoke(proc, args, self, klass)
     if (state == 0) {
 	proc_set_safe_level(proc);
-	result = rb_yield_0(args, self, (self!=Qundef)?CLASS_OF(self):0, pcall, avalue);
+	result = rb_yield_0(args, self, (self!=Qundef)?CLASS_OF(self):0,
+			    pcall | YIELD_PROC_CALL, avalue);
     }
     else if (TAG_DST()) {
@@ -8158,9 +8175,10 @@ proc_arity(proc)
 {
     struct BLOCK *data;
-    NODE *list;
+    NODE *var, *list;
     int n;
 
     Data_Get_Struct(proc, struct BLOCK, data);
-    if (data->var == 0) {
+    var = data->var;
+    if (var == 0) {
 	if (data->body && nd_type(data->body) == NODE_IFUNC &&
 	    data->body->nd_cfnc == bmcall) {
@@ -8169,11 +8187,16 @@ proc_arity(proc)
 	return INT2FIX(0);
     }
-    if (data->var == (NODE*)1) return INT2FIX(0);
-    if (data->var == (NODE*)2) return INT2FIX(0);
-    switch (nd_type(data->var)) {
+    if (var == (NODE*)1) return INT2FIX(0);
+    if (var == (NODE*)2) return INT2FIX(0);
+    if (nd_type(var) == NODE_BLOCK_ARG) {
+	var = var->nd_args;
+	if (var == (NODE*)1) return INT2FIX(0);
+	if (var == (NODE*)2) return INT2FIX(0);
+    }
+    switch (nd_type(var)) {
       default:
 	return INT2FIX(1);
       case NODE_MASGN:
-	list = data->var->nd_head;
+	list = var->nd_head;
 	n = 0;
 	while (list) {
@@ -8181,5 +8204,5 @@ proc_arity(proc)
 	    list = list->nd_next;
 	}
-	if (data->var->nd_args) return INT2FIX(-n-1);
+	if (var->nd_args) return INT2FIX(-n-1);
 	return INT2FIX(n);
     }
Index: parse.y
===================================================================
RCS file: /cvs/ruby/src/ruby/parse.y,v
retrieving revision 1.325
diff -U2 -p -d -r1.325 parse.y
--- parse.y	18 May 2004 05:00:56 -0000	1.325
+++ parse.y	24 May 2004 23:30:09 -0000
@@ -180,4 +180,6 @@ static void top_local_setup();
 #define nd_nest u3.id
 
+#define NEW_BLOCK_VAR(b, v) NEW_NODE(NODE_BLOCK_PASS, 0, b, v)
+
 /* Older versions of Yacc set YYMAXDEPTH to a very low value by default (150,
    for instance).  This is too low for Ruby to parse some files, such as
@@ -263,5 +265,6 @@ static void top_local_setup();
 %type <node> f_arglist f_args f_optarg f_opt f_block_arg opt_f_block_arg
 %type <node> assoc_list assocs assoc kwargs undef_list backref string_dvar
-%type <node> block_var opt_block_var brace_block cmd_brace_block do_block lhs none
+%type <node> for_var block_var opt_block_var block_par
+%type <node> brace_block cmd_brace_block do_block lhs none
 %type <node> mlhs mlhs_head mlhs_basic mlhs_entry mlhs_item mlhs_node
 %type <id>   fitem variable sym symbol operation operation2 operation3
@@ -1590,5 +1593,5 @@ primary		: literal
 			$$ = $4;
 		    }
-		| kFOR block_var kIN {COND_PUSH(1);} expr_value do {COND_POP();}
+		| kFOR for_var kIN {COND_PUSH(1);} expr_value do {COND_POP();}
 		  compstmt
 		  kEND
@@ -1740,6 +1743,72 @@ opt_else	: none
 		;
 
-block_var	: lhs
+for_var 	: lhs
 		| mlhs
+		;
+
+block_par	: mlhs_item
+		    {
+			$$ = NEW_LIST($1);
+		    }
+		| block_par ',' mlhs_item
+		    {
+			$$ = list_append($1, $3);
+		    }
+		;
+
+block_var	: block_par
+		    {
+			if ($1->nd_alen == 1) {
+			    $$ = $1->nd_head;
+			    rb_gc_force_recycle((VALUE)$1);
+			}
+			else {
+			    $$ = NEW_MASGN($1, 0);
+			}
+		    }
+		| block_par ','
+		    {
+			$$ = NEW_MASGN($1, 0);
+		    }
+		| block_par ',' tAMPER lhs
+		    {
+			$$ = NEW_BLOCK_VAR($4, NEW_MASGN($1, 0));
+		    }
+		| block_par ',' tSTAR lhs ',' tAMPER lhs
+		    {
+			$$ = NEW_BLOCK_VAR($7, NEW_MASGN($1, $4));
+		    }
+		| block_par ',' tSTAR ',' tAMPER lhs
+		    {
+			$$ = NEW_BLOCK_VAR($6, NEW_MASGN($1, -1));
+		    }
+		| block_par ',' tSTAR lhs
+		    {
+			$$ = NEW_MASGN($1, $4);
+		    }
+		| block_par ',' tSTAR
+		    {
+			$$ = NEW_MASGN($1, -1);
+		    }
+		| tSTAR lhs ',' tAMPER lhs
+		    {
+			$$ = NEW_BLOCK_VAR($5, NEW_MASGN(0, $2));
+		    }
+		| tSTAR ',' tAMPER lhs
+		    {
+			$$ = NEW_BLOCK_VAR($4, NEW_MASGN(0, -1));
+		    }
+		| tSTAR lhs
+		    {
+			$$ = NEW_MASGN(0, $2);
+		    }
+		| tSTAR
+		    {
+			$$ = NEW_MASGN(0, -1);
+		    }
+		| tAMPER lhs
+		    {
+			$$ = NEW_BLOCK_VAR($2, (NODE*)1);
+		    }
 		;
 
Index: sample/test.rb
===================================================================
RCS file: /cvs/ruby/src/ruby/sample/test.rb,v
retrieving revision 1.88
diff -U2 -p -d -r1.88 test.rb
--- sample/test.rb	19 Mar 2004 07:12:57 -0000	1.88
+++ sample/test.rb	24 May 2004 21:47:40 -0000
@@ -66,4 +66,28 @@ a = *[*[1]]; test_ok(a == 1)
 a = *[*[1,2]]; test_ok(a == [1,2])
 
+a, = nil; test_ok(a == nil)
+a, = 1; test_ok(a == 1)
+a, = []; test_ok(a == nil)
+a, = [1]; test_ok(a == 1)
+a, = [nil]; test_ok(a == nil)
+a, = [[]]; test_ok(a == [])
+a, = 1,2; test_ok(a == 1)
+a, = [1,2]; test_ok(a == 1)
+a, = [*[]]; test_ok(a == nil)
+a, = [*[1]]; test_ok(a == 1)
+a, = *[1,2]; test_ok(a == 1)
+a, = [*[1,2]]; test_ok(a == 1)
+
+a, = *nil; test_ok(a == nil)
+a, = *1; test_ok(a == 1)
+a, = *[]; test_ok(a == nil)
+a, = *[1]; test_ok(a == 1)
+a, = *[nil]; test_ok(a == nil)
+a, = *[[]]; test_ok(a == [])
+a, = *[1,2]; test_ok(a == 1)
+a, = *[*[]]; test_ok(a == nil)
+a, = *[*[1]]; test_ok(a == 1)
+a, = *[*[1,2]]; test_ok(a == 1)
+
 *a = nil; test_ok(a == [nil])
 *a = 1; test_ok(a == [1])
@@ -127,4 +151,25 @@ def f; yield *[[]]; end; f {|a| test_ok(
 def f; yield *[*[1]]; end; f {|a| test_ok(a == 1)}
 
+def f; yield; end; f {|a,| test_ok(a == nil)}
+def f; yield nil; end; f {|a,| test_ok(a == nil)}
+def f; yield 1; end; f {|a,| test_ok(a == 1)}
+def f; yield []; end; f {|a,| test_ok(a == nil)}
+def f; yield [1]; end; f {|a,| test_ok(a == 1)}
+def f; yield [nil]; end; f {|a,| test_ok(a == nil)}
+def f; yield [[]]; end; f {|a,| test_ok(a == [])}
+def f; yield [*[]]; end; f {|a,| test_ok(a == nil)}
+def f; yield [*[1]]; end; f {|a,| test_ok(a == 1)}
+def f; yield [*[1,2]]; end; f {|a,| test_ok(a == 1)}
+
+def f; yield *nil; end; f {|a,| test_ok(a == nil)}
+def f; yield *1; end; f {|a,| test_ok(a == 1)}
+def f; yield *[]; end; f {|a,| test_ok(a == nil)}
+def f; yield *[1]; end; f {|a,| test_ok(a == 1)}
+def f; yield *[nil]; end; f {|a,| test_ok(a == nil)}
+def f; yield *[[]]; end; f {|a,| test_ok(a == [])}
+def f; yield *[*[]]; end; f {|a,| test_ok(a == nil)}
+def f; yield *[*[1]]; end; f {|a,| test_ok(a == 1)}
+def f; yield *[*[1,2]]; end; f {|a,| test_ok(a == 1)}
+
 def f; yield; end; f {|*a| test_ok(a == [])}
 def f; yield nil; end; f {|*a| test_ok(a == [nil])}
@@ -1001,13 +1046,19 @@ IterTest.new([[0,0]]).each0 {|x| test_ok
 IterTest.new([[8,8]]).each8 {|x| test_ok(x == [8,8])}
 
-def m
-  test_ok(block_given?)
+def m0(v)
+  v
 end
-m{p 'test'}
+
+def m1
+  m0(block_given?)
+end
+test_ok(m1{p 'test'})
+test_ok(!m1)
 
 def m
-  test_ok(block_given?,&proc{})
+  m0(block_given?,&proc{})
 end
-m{p 'test'}
+test_ok(m1{p 'test'})
+test_ok(!m1)
 
 class C
@@ -1079,4 +1130,7 @@ test_ok(get_block(&lambda).class == Proc
 test_ok(Proc.new{|a,| a}.call(1,2,3) == 1)
 argument_test(true, Proc.new{|a,|}, 1,2)
+
+test_ok(Proc.new{|&b| b.call(10)}.call {|x| x} == 10)
+test_ok(Proc.new{|a,&b| b.call(a)}.call(12) {|x| x} == 12)
 
 def test_return1
Index: test/ruby/test_proc.rb
===================================================================
RCS file: /cvs/ruby/src/ruby/test/ruby/test_proc.rb,v
retrieving revision 1.8
diff -U2 -p -d -r1.8 test_proc.rb
--- test/ruby/test_proc.rb	18 Mar 2004 10:08:24 -0000	1.8
+++ test/ruby/test_proc.rb	24 May 2004 21:43:10 -0000
@@ -87,3 +87,8 @@ class TestProc < Test::Unit::TestCase
     assert_not_equal(a, b)
   end
+
+  def test_block_par
+    assert_equal(10, Proc.new{|&b| b.call(10)}.call {|x| x})
+    assert_equal(12, Proc.new{|a,&b| b.call(a)}.call(12) {|x| x})
+  end
 end


-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦

In This Thread