[#34011] Should --verbose be equal to -v ? — Yugui <yugui@...>

Yuguiです。

15 messages 2008/03/10
[#34012] Re: Should --verbose be equal to -v ? — Yukihiro Matsumoto <matz@...> 2008/03/10

まつもと ゆきひろです

[#34105] rational.rb, complex.rb and mathn.rb — Tadayoshi Funaba <tadf@...>

rational と complex が組み込みになったことで、lib/mathn.rb の意義は薄

29 messages 2008/03/22
[#34106] Re: rational.rb, complex.rb and mathn.rb — Tadayoshi Funaba <tadf@...> 2008/03/22

現時点で rational.rb と complex.rb を残しているのは、それが無難だから

[#34107] Re: rational.rb, complex.rb and mathn.rb — Tadayoshi Funaba <tadf@...> 2008/03/22

で、かなり選択肢を絞った叩き台です。

[#34120] Re: rational.rb, complex.rb and mathn.rb — keiju@... (石塚圭樹) 2008/03/24

けいじゅ@いしつかです.

[#34125] Re: rational.rb, complex.rb and mathn.rb — Shin-ichiro HARA <sinara@...> 2008/03/25

原です。

[#34130] Re: rational.rb, complex.rb and mathn.rb — Tadayoshi Funaba <tadf@...> 2008/03/25

> 私も Complex の組み込みは Rational とは比較にならないくらい、仕様が決め

[#34158] Complex組み込み — Masahiro TANAKA <masa16.tanaka@...>

Complexが組み込みになるそうですが、これはcomplex.rbを踏襲して、

49 messages 2008/03/27
[#34161] Re: Complex組み込み — Shin-ichiro HARA <sinara@...> 2008/03/28

原です。

[#34168] Re: Complex組み込み — Tadayoshi Funaba <tadf@...> 2008/03/28

> 今までの Complex は、complex.rb にほぼ残して、たとえば Rational 成分

[#34186] Re: Complex組み込み — Shin-ichiro HARA <sinara@...> 2008/03/31

原です。

[#34187] Re: Complex組み込み — Tadayoshi Funaba <tadf@...> 2008/03/31

> そうです。Complex が難しい、という話を書いておくと、

[#34193] Re: Complex組み込み — Yukihiro Matsumoto <matz@...> 2008/03/31

まつもと ゆきひろです

[#34203] Re: Complex組み込み — Tadayoshi Funaba <tadf@...> 2008/04/01

> |僕としては、/ 演算子の振舞いについて前向きに検討してほしいです。

[#34215] Re: Complex組み込み — Yukihiro Matsumoto <matz@...> 2008/04/02

まつもと ゆきひろです

[#34166] Re: Complex組み込み — Tadayoshi Funaba <tadf@...> 2008/03/28

> となるようですが、別の実装として、

[ruby-dev:34085] Re: rational, complex and mathn

From: Nobuyoshi Nakada <nobu@...>
Date: 2008-03-18 08:59:51 UTC
List: ruby-dev #34085
なかだです。

At Sat, 15 Mar 2008 12:52:19 +0900,
Tadayoshi Funaba wrote in [ruby-dev:34060]:
> おそらく、明日作業します。石塚さんが rational.rb、complex.rb mathn.rb
> を公開されて以来、4121 日ぶりの大改訂になるのではないかと思います。
> 
> おかしなところ、受け入れる側から見て気持の悪いところなどは、どんどん直
> してもらいたいと思います。最悪、何時でも revert できるのでやってしまい
> ます。

数値リテラルでは連続するアンダースコアは許されなくなっていますか
ら、ComplexやRationalでも揃えたほうがいいんじゃないでしょうか。

# インデントが他と違うのがちょっと気になるというのもあるけど。


Index: complex.c
===================================================================
--- complex.c	(revision 15792)
+++ complex.c	(working copy)
@@ -203,4 +203,5 @@ nucomp_s_canonicalize_internal(VALUE kla
 }
 
+#if 0
 static VALUE
 nucomp_s_canonicalize(int argc, VALUE *argv, VALUE klass)
@@ -236,4 +237,5 @@ nucomp_s_canonicalize(int argc, VALUE *a
   return nucomp_s_canonicalize_internal(klass, real, image);
 }
+#endif
 
 static VALUE
@@ -460,4 +462,5 @@ m_atan2_bang(VALUE y, VALUE x)
 }
 
+#if 0
 static VALUE
 m_hypot(VALUE x, VALUE y)
@@ -467,4 +470,5 @@ m_hypot(VALUE x, VALUE y)
 }
 #endif
+#endif
 
 static VALUE
@@ -627,4 +631,5 @@ nucomp_rdiv(VALUE self, VALUE other)
 }
 
+#if 0
 static VALUE
 nucomp_fdiv(VALUE self, VALUE other)
@@ -636,4 +641,5 @@ nucomp_fdiv(VALUE self, VALUE other)
 			      f_to_f(dat->image)), other);
 }
+#endif
 
 static VALUE
@@ -789,4 +795,5 @@ nucomp_conjugate(VALUE self)
 }
 
+#if 0
 static VALUE
 nucomp_real_p(VALUE self)
@@ -813,4 +820,5 @@ nucomp_inexact_p(VALUE self)
   return f_boolcast(!nucomp_exact_p(self));
 }
+#endif
 
 inline static long
@@ -979,15 +987,15 @@ nucomp_to_s(VALUE self)
   else {
     s = f_to_s(dat->real);
-    rb_str_concat(s, rb_str_new2(!impos ? "-" : "+"));
+    rb_str_cat2(s, (!impos ? "-" : "+"));
   }
 
   if (k_rational_p(dat->image) &&
       !f_one_p(f_denominator(dat->image))) {
-    rb_str_concat(s, rb_str_new2("("));
+    rb_str_cat2(s, "(");
     rb_str_concat(s, f_to_s(rezero ? dat->image : f_abs(dat->image)));
-    rb_str_concat(s, rb_str_new2(")i"));
+    rb_str_cat2(s, ")i");
   } else {
     rb_str_concat(s, f_to_s(rezero ? dat->image : f_abs(dat->image)));
-    rb_str_concat(s, rb_str_new2("i"));
+    rb_str_cat2(s, "i");
   }
 
@@ -1004,7 +1012,7 @@ nucomp_inspect(VALUE self)
   s = rb_str_new2("Complex(");
   rb_str_concat(s, f_inspect(dat->real));
-  rb_str_concat(s, rb_str_new2(", "));
+  rb_str_cat2(s, ", ");
   rb_str_concat(s, f_inspect(dat->image));
-  rb_str_concat(s, rb_str_new2(")"));
+  rb_str_cat2(s, ")");
 
   return s;
@@ -1110,5 +1118,5 @@ numeric_to_c(VALUE self)
 
 static VALUE comp_pat1, comp_pat2, a_slash, a_dot_and_an_e,
-  image_garbages_pat, null_string, underscores_pat, an_underscore;
+    image_garbages_pat, null_string;
 
 #define DIGITS "(?:\\d(?:_\\d|\\d)*)"
@@ -1123,13 +1131,13 @@ static void
 make_patterns(void)
 {
-  static char *comp_pat1_source = PATTERN1;
-  static char *comp_pat2_source = PATTERN2;
-  static char *image_garbages_pat_source = "[+\\(\\)iIjJ]";
-  static char *underscores_pat_source = "_+";
+  static const char comp_pat1_source[] = PATTERN1;
+  static const char comp_pat2_source[] = PATTERN2;
+  static const char image_garbages_pat_source[] = "[+\\(\\)iIjJ]";
+#define REG_NEW(s) rb_reg_new(s, sizeof(s) - 1, 0)
 
-  comp_pat1 = rb_reg_new(comp_pat1_source, strlen(comp_pat1_source), 0);
+  comp_pat1 = REG_NEW(comp_pat1_source);
   rb_global_variable(&comp_pat1);
 
-  comp_pat2 = rb_reg_new(comp_pat2_source, strlen(comp_pat2_source), 0);
+  comp_pat2 = REG_NEW(comp_pat2_source);
   rb_global_variable(&comp_pat2);
 
@@ -1140,6 +1148,5 @@ make_patterns(void)
   rb_global_variable(&a_dot_and_an_e);
 
-  image_garbages_pat = rb_reg_new(image_garbages_pat_source,
-				  strlen(image_garbages_pat_source), 0);
+  image_garbages_pat = REG_NEW(image_garbages_pat_source);
   rb_global_variable(&image_garbages_pat);
 
@@ -1147,10 +1154,5 @@ make_patterns(void)
   rb_global_variable(&null_string);
 
-  underscores_pat = rb_reg_new(underscores_pat_source,
-			       strlen(underscores_pat_source), 0);
-  rb_global_variable(&underscores_pat);
-
-  an_underscore = rb_str_new2("_");
-  rb_global_variable(&an_underscore);
+#undef REG_NEW
 }
 
@@ -1247,6 +1249,5 @@ static VALUE
 string_to_c(VALUE self)
 {
-  VALUE s = f_gsub(self, underscores_pat, an_underscore);
-  VALUE a = string_to_c_internal(s);
+  VALUE a = string_to_c_internal(self);
   if (!NIL_P(RARRAY_PTR(a)[0]))
     return RARRAY_PTR(a)[0];
Index: rational.c
===================================================================
--- rational.c	(revision 15792)
+++ rational.c	(working copy)
@@ -231,4 +231,5 @@ nurat_s_canonicalize_internal(VALUE klas
 }
 
+#if 0
 static VALUE
 nurat_s_canonicalize(int argc, VALUE *argv, VALUE klass)
@@ -260,4 +261,5 @@ nurat_s_canonicalize(int argc, VALUE *ar
   return nurat_s_canonicalize_internal(klass, num, den);
 }
+#endif
 
 static VALUE
@@ -585,4 +587,5 @@ nurat_divmod(VALUE self, VALUE other)
 }
 
+#if 0
 static VALUE
 nurat_quot(VALUE self, VALUE other)
@@ -590,4 +593,6 @@ nurat_quot(VALUE self, VALUE other)
   return f_truncate(f_div(self, other));
 }
+#endif
+
 static VALUE
 nurat_rem(VALUE self, VALUE other)
@@ -597,4 +602,5 @@ nurat_rem(VALUE self, VALUE other)
 }
 
+#if 0
 static VALUE
 nurat_quotrem(VALUE self, VALUE other)
@@ -603,4 +609,5 @@ nurat_quotrem(VALUE self, VALUE other)
   return rb_assoc_new(val, f_sub(self, f_mul(other, val)));
 }
+#endif
 
 static VALUE
@@ -613,4 +620,5 @@ nurat_abs(VALUE self)
 }
 
+#if 0
 static VALUE
 nurat_true(VALUE self)
@@ -618,4 +626,5 @@ nurat_true(VALUE self)
   return Qtrue;
 }
+#endif
 
 static VALUE
@@ -775,5 +784,5 @@ float_to_r(VALUE self)
 }
 
-static VALUE rat_pat, an_e_pat, a_dot_pat, underscores_pat, an_underscore;
+static VALUE rat_pat, an_e_pat, a_dot_pat;
 
 #define DIGITS "(?:\\d(?:_\\d|\\d)*)"
@@ -785,24 +794,19 @@ static void
 make_patterns(void)
 {
-  static char *rat_pat_source = PATTERN;
-  static char *an_e_pat_source = "[eE]";
-  static char *a_dot_pat_source = "\\.";
-  static char *underscores_pat_source = "_+";
+  static const char rat_pat_source[] = PATTERN;
+  static const char an_e_pat_source[] = "[eE]";
+  static const char a_dot_pat_source[] = "\\.";
+#define REG_NEW(s) rb_reg_new(s, sizeof(s) - 1, 0)
 
-  rat_pat = rb_reg_new(rat_pat_source, strlen(rat_pat_source), 0);
+  rat_pat = REG_NEW(rat_pat_source);
   rb_global_variable(&rat_pat);
 
-  an_e_pat = rb_reg_new(an_e_pat_source, strlen(an_e_pat_source), 0);
+  an_e_pat = REG_NEW(an_e_pat_source);
   rb_global_variable(&an_e_pat);
 
-  a_dot_pat = rb_reg_new(a_dot_pat_source, strlen(a_dot_pat_source), 0);
+  a_dot_pat = REG_NEW(a_dot_pat_source);
   rb_global_variable(&a_dot_pat);
 
-  underscores_pat = rb_reg_new(underscores_pat_source,
-			       strlen(underscores_pat_source), 0);
-  rb_global_variable(&underscores_pat);
-
-  an_underscore = rb_str_new2("_");
-  rb_global_variable(&an_underscore);
+#undef REG_NEW
 }
 
@@ -909,6 +913,5 @@ static VALUE
 string_to_r(VALUE self)
 {
-  VALUE s = f_gsub(self, underscores_pat, an_underscore);
-  VALUE a = string_to_r_internal(s);
+  VALUE a = string_to_r_internal(self);
   if (!NIL_P(RARRAY_PTR(a)[0]))
     return RARRAY_PTR(a)[0];


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

In This Thread