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

ruby-changes:42763

From: akr <ko1@a...>
Date: Sat, 30 Apr 2016 14:33:35 +0900 (JST)
Subject: [ruby-changes:42763] akr:r54837 (trunk): {Fixnum, Bignum}#-@ is unified into Integer.

akr	2016-04-30 15:30:08 +0900 (Sat, 30 Apr 2016)

  New Revision: 54837

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

  Log:
    {Fixnum,Bignum}#-@ is unified into Integer.
    
    * numeric.c (rb_int_uminus): {Fixnum,Bignum}#-@ is unified into
      Integer.
    
    * bignum.c (rb_big_uminus): Don't define Bignum#-@.

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c
    trunk/numeric.c
Index: bignum.c
===================================================================
--- bignum.c	(revision 54836)
+++ bignum.c	(revision 54837)
@@ -5529,13 +5529,6 @@ rb_big_eql(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/bignum.c#L5529
     return Qtrue;
 }
 
-/*
- * call-seq:
- *    -big   ->  integer
- *
- * Unary minus (returns an integer whose value is 0-big)
- */
-
 VALUE
 rb_big_uminus(VALUE x)
 {
@@ -6890,7 +6883,6 @@ Init_Bignum(void) https://github.com/ruby/ruby/blob/trunk/bignum.c#L6883
     rb_cBignum = rb_define_class("Bignum", rb_cInteger);
 
     rb_define_method(rb_cBignum, "coerce", rb_big_coerce, 1);
-    rb_define_method(rb_cBignum, "-@", rb_big_uminus, 0);
     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_mul, 1);
Index: numeric.c
===================================================================
--- numeric.c	(revision 54836)
+++ numeric.c	(revision 54837)
@@ -3122,11 +3122,12 @@ int_ord(VALUE num) https://github.com/ruby/ruby/blob/trunk/numeric.c#L3122
 
 
 /*
- * Document-method: Fixnum#-@
+ * Document-method: Integer#-@
  * call-seq:
- *   -fix  ->  integer
+ *   -int  ->  integer
  *
- * Negates +fix+, which may return a Bignum.
+ * Negates +int+.
+ * (returns an integer whose value is 0-int)
  */
 
 static VALUE
@@ -4834,7 +4835,7 @@ Init_Numeric(void) https://github.com/ruby/ruby/blob/trunk/numeric.c#L4835
 
     rb_cFixnum = rb_define_class("Fixnum", rb_cInteger);
 
-    rb_define_method(rb_cFixnum, "-@", fix_uminus, 0);
+    rb_define_method(rb_cFixnum, "-@", rb_int_uminus, 0);
     rb_define_method(rb_cFixnum, "+", fix_plus, 1);
     rb_define_method(rb_cFixnum, "-", fix_minus, 1);
     rb_define_method(rb_cFixnum, "*", fix_mul, 1);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 54836)
+++ ChangeLog	(revision 54837)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Apr 30 15:29:24 2016  Tanaka Akira  <akr@f...>
+
+	* numeric.c (rb_int_uminus): {Fixnum,Bignum}#-@ is unified into
+	  Integer.
+
+	* bignum.c (rb_big_uminus): Don't define Bignum#-@.
+
 Sat Apr 30 14:42:20 2016  Tanaka Akira  <akr@f...>
 
 	* numeric.c (rb_int_idiv): {Fixnum,Bignum}#div is unified into

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

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