[前][次][番号順一覧][スレッド一覧]

ruby-changes:42775

From: akr <ko1@a...>
Date: Sat, 30 Apr 2016 20:12:55 +0900 (JST)
Subject: [ruby-changes:42775] akr:r54849 (trunk): Define Integer#- instead of Bignum#-.

akr	2016-04-30 21:09:31 +0900 (Sat, 30 Apr 2016)

  New Revision: 54849

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54849

  Log:
    Define Integer#- instead of Bignum#-.
    
    * numeric.c (rb_int_minus): Define Integer#-.
    
    * bignum.c (rb_big_minus): Don't define Bignum#-.

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c
    trunk/numeric.c
Index: numeric.c
===================================================================
--- numeric.c	(revision 54848)
+++ numeric.c	(revision 54849)
@@ -3279,9 +3279,10 @@ rb_int_plus(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L3279
 }
 
 /*
+ * Document-method: Integer#-
  * Document-method: Fixnum#-
  * call-seq:
- *   fix - numeric  ->  numeric_result
+ *   int - numeric  ->  numeric_result
  *
  * Performs subtraction: the class of the resulting object depends on the class
  * of +numeric+ and on the magnitude of the result. It may return a Bignum.
@@ -4940,6 +4941,7 @@ Init_Numeric(void) https://github.com/ruby/ruby/blob/trunk/numeric.c#L4941
     rb_define_method(rb_cInteger, "-@", rb_int_uminus, 0);
     rb_define_method(rb_cFixnum, "+", fix_plus, 1);
     rb_define_method(rb_cFixnum, "-", fix_minus, 1);
+    rb_define_method(rb_cInteger, "-", rb_int_minus, 1);
     rb_define_method(rb_cFixnum, "*", fix_mul, 1);
     rb_define_method(rb_cInteger, "*", rb_int_mul, 1);
     rb_define_method(rb_cFixnum, "/", fix_div, 1);
Index: bignum.c
===================================================================
--- bignum.c	(revision 54848)
+++ bignum.c	(revision 54849)
@@ -5803,13 +5803,6 @@ rb_big_plus(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/bignum.c#L5803
     }
 }
 
-/*
- *  call-seq:
- *     big - other  -> Numeric
- *
- *  Subtracts other from big, returning the result.
- */
-
 VALUE
 rb_big_minus(VALUE x, VALUE y)
 {
@@ -6836,7 +6829,6 @@ Init_Bignum(void) https://github.com/ruby/ruby/blob/trunk/bignum.c#L6829
 
     rb_define_method(rb_cBignum, "coerce", rb_big_coerce, 1);
     rb_define_method(rb_cBignum, "+", rb_big_plus, 1);
-    rb_define_method(rb_cBignum, "-", rb_big_minus, 1);
     rb_define_method(rb_cBignum, "/", rb_big_div, 1);
 
     rb_define_method(rb_cBignum, "===", rb_big_eq, 1);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 54848)
+++ ChangeLog	(revision 54849)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Apr 30 21:01:20 2016  Tanaka Akira  <akr@f...>
+
+	* numeric.c (rb_int_minus): Define Integer#-.
+
+	* bignum.c (rb_big_minus): Don't define Bignum#-.
+
 Sat Apr 30 20:53:33 2016  Tanaka Akira  <akr@f...>
 
 	* numeric.c (rb_int_mul): Define Integer#*.

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]