e$B0J2<$N$h$&$Ke(B (1…5).step(1.5) {|x| p x} e$B$He(B
(1…5).step(SimpleDelegator.new(1.5)) {|x| p x} e$B$N7k2L$,0[$Je(B
e$B$k$N$OJQ$G$O$J$$$G$7$g$&$+!#e(B
% ./ruby -ve ‘(1…5).step(1.5) {|x| p x}’
ruby 1.9.0 (2008-05-20 revision 16494) [i686-linux]
1
2.5
4.0
% ./ruby -rdelegate -e ‘(1…5).step(SimpleDelegator.new(1.5)) {|x| p x}’
1
2
3
4
5
e$B$J$+$@$G$9!#e(B
At Wed, 21 May 2008 00:37:24 +0900,
Tanaka A. wrote in [ruby-dev:34775]:
e$B0J2<$N$h$&$Ke(B (1…5).step(1.5) {|x| p x} e$B$He(B
(1…5).step(SimpleDelegator.new(1.5)) {|x| p x} e$B$N7k2L$,0[$Je(B
e$B$k$N$OJQ$G$O$J$$$G$7$g$&$+!#e(B
e$B$d$O$j!"e(BFloat#to_inte$B$OGQ;_$9$k$3$H$r<gD%$7$^$9!#e(B
Index: numeric.c
— numeric.c (revision 16501)
+++ numeric.c (working copy)
@@ -454,18 +454,4 @@ num_nonzero_p(VALUE num)
}
-/*
-
-
-
-
- Invokes the child class’s
to_i
method to convert
-
- */
-
-static VALUE
-num_to_int(VALUE num)
-{
- return rb_funcall(num, id_to_i, 0, 0);
-}
-
/********************************************************************
@@ -3116,5 +3102,4 @@ Init_Numeric(void)
rb_define_method(rb_cNumeric, “remainder”, num_remainder, 1);
rb_define_method(rb_cNumeric, “abs”, num_abs, 0);
-
rb_define_method(rb_cNumeric, “to_int”, num_to_int, 0);
rb_define_method(rb_cNumeric, “scalar?”, num_scalar_p, 0);
@@ -3247,5 +3232,4 @@ Init_Numeric(void)
rb_define_method(rb_cFloat, “to_i”, flo_truncate, 0);
-
rb_define_method(rb_cFloat, “to_int”, flo_truncate, 0);
rb_define_method(rb_cFloat, “floor”, flo_floor, 0);
rb_define_method(rb_cFloat, “ceil”, flo_ceil, 0);
Index: range.c
===================================================================
— range.c (revision 16501)
+++ range.c (working copy)
@@ -307,6 +307,7 @@ range_step(int argc, VALUE *argv, VALUE
else {
rb_scan_args(argc, argv, “01”, &step);
-
if (!rb_obj_is_kind_of(step, rb_cNumeric)) {
-
step = rb_to_int(step);
- tmp = rb_check_to_integer(step, “to_int”);
- if (!NIL_P(tmp)) {
-
step = tmp;
}
if (rb_funcall(step, ‘<’, 1, INT2FIX(0))) {
Index: lib/delegate.rb
===================================================================
— lib/delegate.rb (revision 16501)
+++ lib/delegate.rb (working copy)
@@ -153,7 +153,7 @@ class Delegator
call through __getobj__.
- def respond_to?(m, *priv)
return true if super
e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B
In message “Re: [ruby-dev:34780] Re:
(1…5).step(SimpleDelegator.new(1.5)) {|x| p x} differ from
(1…5).step(1.5) {|x| p x}”
on Wed, 21 May 2008 10:16:16 +0900, Nobuyoshi N.
[email protected] writes:
|At Wed, 21 May 2008 00:37:24 +0900,
|Tanaka A. wrote in [ruby-dev:34775]:
|> e$B0J2<$N$h$&$Ke(B (1…5).step(1.5) {|x| p x} e$B$He(B
|> (1…5).step(SimpleDelegator.new(1.5)) {|x| p x} e$B$N7k2L$,0[$Je(B
|> e$B$k$N$OJQ$G$O$J$$$G$7$g$&$+!#e(B
|
|e$B$d$O$j!"e(BFloat#to_inte$B$OGQ;_$9$k$3$H$r<gD%$7$^$9!#e(B
to_floate$B$rMQ0U$7$F$=$C$A$r@h$K8+$k!"$H$+!#e(B
1.9e$B$@$7!"GQ;_$7$F$O$$$1$J$$$H$O8@$o$J$$$1$I!"1F6AHO0O$r8+@Qe(B
e$B$b$j$?$$5$$b$7$^$9!#e(B