[#636] doc/NEWS — Matt Armstrong <matt@...>

22 messages 2002/12/15

Re: [patch] doc/NEWS

From: Matt Armstrong <matt@...>
Date: 2002-12-16 04:37:22 UTC
List: ruby-core #641

nobu.nokada@softhome.net writes:

>> +: Class#inherited

[...]

> This feature has existed but the timing was changed.

[...]

> That is "inherited" will be called after subclass is defined.
> How should we describe this?

I tried to explain simply (attached as patch against current
doc/NEWS).

Also, does this change log of yours change any behavior?  This is
where I discovered the "inherited" method in the first place -- I see
now the new timing of "inherited" was done by matz later.

Fri Jan 11 05:06:25 2002  Nobuyoshi Nakada  <nobu.nakada@nifty.ne.jp>

	* class.c (rb_make_metaclass): [new]

	* class.c (rb_define_class_id): use rb_make_metaclass(), don't
	  call Class#inherited hook.

	* class.c (rb_class_inherited): [new]

	* class.c (rb_define_class): call Class#inherited hook here.

	* class.c (rb_define_class_under): ditto after class path is set.

	* class.c (rb_singleton_class): use rb_make_metaclass().

	* eval.c (rb_eval): same as rb_define_class_under().

	* intern.h: prototypes of rb_make_metaclass() and
	  rb_class_inherited().

	* object.c (rb_class_s_new): use rb_make_metaclass() and
	  rb_class_inherited().

	* object.c (Init_Object): use rb_make_metaclass().

	* struct.c (make_struct): use rb_class_inherited().


Attachments (1)

NEWS.patch (2.29 KB, text/x-patch)
? ruby-cvs
Index: re.c
===================================================================
RCS file: /src/ruby/re.c,v
retrieving revision 1.86
diff -u -r1.86 re.c
--- re.c	12 Dec 2002 09:17:32 -0000	1.86
+++ re.c	16 Dec 2002 04:34:32 -0000
@@ -1129,12 +1129,20 @@
 }
 
 static VALUE
-rb_reg_match_m(re, str)
-    VALUE re, str;
+rb_reg_match_m(argc, argv, re)
+    int argc;
+    VALUE *argv;
+    VALUE re;
 {
-    VALUE result = rb_reg_match(re, str);
+    VALUE str, initpos, result;
+    long pos = 0;
 
-    if (NIL_P(result)) return Qnil;
+    if (rb_scan_args(argc, argv, "11", &str, &initpos) == 2) {
+	pos = NUM2LONG(initpos);
+    }
+    if (NIL_P(str)) return Qnil;
+    StringValue(str);
+    if (rb_reg_search(re, str, pos, 0) < 0) return Qnil;
     result = rb_backref_get();
     rb_match_busy(result);
     return result;
@@ -1585,7 +1593,7 @@
     rb_define_method(rb_cRegexp, "=~", rb_reg_match, 1);
     rb_define_method(rb_cRegexp, "===", rb_reg_match, 1);
     rb_define_method(rb_cRegexp, "~", rb_reg_match2, 0);
-    rb_define_method(rb_cRegexp, "match", rb_reg_match_m, 1);
+    rb_define_method(rb_cRegexp, "match", rb_reg_match_m, -1);
     rb_define_method(rb_cRegexp, "to_s", rb_reg_to_s, 0);
     rb_define_method(rb_cRegexp, "inspect", rb_reg_inspect, 0);
     rb_define_method(rb_cRegexp, "source", rb_reg_source, 0);
Index: doc/NEWS
===================================================================
RCS file: /src/ruby/doc/NEWS,v
retrieving revision 1.51
diff -u -r1.51 NEWS
--- doc/NEWS	15 Dec 2002 21:15:58 -0000	1.51
+++ doc/NEWS	16 Dec 2002 04:34:33 -0000
@@ -2,15 +2,9 @@
 
 : Class#inherited
 
-  Method is called when Class is inherited by another class.
-
-	class A; end
-	def A.inherited(by)
-          puts "A inherited by #{by.inspect}"
-        end
-        class B < A; end
-
-        Prints out "A inherited by B"
+  The "inherited" method is now called after the execution of the new
+  subclass class' body.  Previously it was called at the beginning of
+  the subclass' body.
 
 : String#to_i
 
@@ -143,9 +137,10 @@
 
 : Array#pack, String#unpack
 
-  New templates 'q' and 'Q' for 64bit integer (signed and unsigned respectively).
+  New templates 'q' and 'Q' for 64bit integer (signed and unsigned
+  respectively).
 
-: Array#new
+: Array.new
 
   Now takes block to fill initial values.  E.g.
 

In This Thread