summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-20 15:01:44 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-20 15:01:44 +0000
commit1292c5ec58507fb721ba646672b15a9f163bfae9 (patch)
tree38275944d4e87961a304c4854b2dc37d41fc7eed
parentcc659d2f1b120fda6b085a7a51ac4115397bf9ef (diff)
* enum.c (enum_chunk): Deprecate the state management.
(enum_slice_before): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--NEWS4
-rw-r--r--enum.c14
3 files changed, 19 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 4802b69..92ef341 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Sep 20 23:58:21 2014 Tanaka Akira <akr@fsij.org>
+
+ * enum.c (enum_chunk): Deprecate the state management.
+ (enum_slice_before): Ditto.
+
Sat Sep 20 15:39:11 2014 Tanaka Akira <akr@fsij.org>
* enum.c (enum_slice_when): New method: Enumerable#slice_when.
diff --git a/NEWS b/NEWS
index aadfd47..a9544b8 100644
--- a/NEWS
+++ b/NEWS
@@ -87,6 +87,10 @@ with all sufficient information, see the ChangeLog file.
=== 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]
diff --git a/enum.c b/enum.c
index 7657e04..bea3c5b 100644
--- a/enum.c
+++ b/enum.c
@@ -2751,7 +2751,7 @@ chunk_i(RB_BLOCK_CALL_FUNC_ARGLIST(yielder, enumerator))
/*
* 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 enumerable)
{
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(yielder, enumerator))
* 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, VALUE enumerable)
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);