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

ruby-changes:35571

From: akr <ko1@a...>
Date: Sun, 21 Sep 2014 00:01:59 +0900 (JST)
Subject: [ruby-changes:35571] akr:r47653 (trunk): * enum.c (enum_chunk): Deprecate the state management.

akr	2014-09-21 00:01:44 +0900 (Sun, 21 Sep 2014)

  New Revision: 47653

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

  Log:
    * enum.c (enum_chunk): Deprecate the state management.
      (enum_slice_before): Ditto.

  Modified files:
    trunk/ChangeLog
    trunk/NEWS
    trunk/enum.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47652)
+++ ChangeLog	(revision 47653)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Sep 20 23:58:21 2014  Tanaka Akira  <akr@f...>
+
+	* enum.c (enum_chunk): Deprecate the state management.
+	  (enum_slice_before): Ditto.
+
 Sat Sep 20 15:39:11 2014  Tanaka Akira  <akr@f...>
 
 	* enum.c (enum_slice_when): New method: Enumerable#slice_when.
Index: enum.c
===================================================================
--- enum.c	(revision 47652)
+++ enum.c	(revision 47653)
@@ -2751,7 +2751,7 @@ chunk_i(RB_BLOCK_CALL_FUNC_ARGLIST(yield https://github.com/ruby/ruby/blob/trunk/enum.c#L2751
 /*
  *  call-seq:
  *     enum.chunk { |elt| ... }                       -> an_enumerator
- *     enum.chunk(initial_state) { |elt, state| ... } -> an_enumerator
+ *     enum.chunk(initial_state) { |elt, state| ... } -> an_enumerator (deprecated)
  *
  *  Enumerates over the items, chunking them together based on the return
  *  value of the block.
@@ -2847,10 +2847,13 @@ enum_chunk(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/enum.c#L2847
 {
     VALUE initial_state;
     VALUE enumerator;
+    int n;
 
     if (!rb_block_given_p())
 	rb_raise(rb_eArgError, "no block given");
-    rb_scan_args(argc, argv, "01", &initial_state);
+    n = rb_scan_args(argc, argv, "01", &initial_state);
+    if (n != 0)
+        rb_warn("initial_state given for chunk.  (Use Enumerator.new with lexical scope variables.)");
 
     enumerator = rb_obj_alloc(rb_cEnumerator);
     rb_ivar_set(enumerator, rb_intern("chunk_enumerable"), enumerable);
@@ -2926,7 +2929,7 @@ slicebefore_i(RB_BLOCK_CALL_FUNC_ARGLIST https://github.com/ruby/ruby/blob/trunk/enum.c#L2929
  *  call-seq:
  *     enum.slice_before(pattern)                             -> an_enumerator
  *     enum.slice_before { |elt| bool }                       -> an_enumerator
- *     enum.slice_before(initial_state) { |elt, state| bool } -> an_enumerator
+ *     enum.slice_before(initial_state) { |elt, state| bool } -> an_enumerator (deprecated)
  *
  *  Creates an enumerator for each chunked elements.
  *  The beginnings of chunks are defined by _pattern_ and the block.
@@ -3066,7 +3069,10 @@ enum_slice_before(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/enum.c#L3069
 
     if (rb_block_given_p()) {
         VALUE initial_state;
-        rb_scan_args(argc, argv, "01", &initial_state);
+        int n;
+        n = rb_scan_args(argc, argv, "01", &initial_state);
+        if (n != 0)
+	    rb_warn("initial_state given for slice_before.  (Use Enumerator.new with lexical scope variables.)");
         enumerator = rb_obj_alloc(rb_cEnumerator);
         rb_ivar_set(enumerator, rb_intern("slicebefore_sep_pred"), rb_block_proc());
         rb_ivar_set(enumerator, rb_intern("slicebefore_initial_state"), initial_state);
Index: NEWS
===================================================================
--- NEWS	(revision 47652)
+++ NEWS	(revision 47653)
@@ -87,6 +87,10 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L87
 
 === Core classes compatibility issues (excluding feature bug fixes)
 
+* Enumerable
+  * Enumerable#slice_before's state management deprecated.
+  * Enumerable#chunk's state management deprecated.
+
 * GC
   * incompatible changes:
     * Rename GC.stat entries. [Feature #9924]

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

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