aboutsummaryrefslogtreecommitdiffstats
path: root/object.c
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2020-07-03 09:52:35 -0700
committerGitHub <noreply@github.com>2020-07-03 09:52:35 -0700
commitf3a0d7a2035e9f5e0c70effd55732607e3def263 (patch)
tree697ff4e3c14edb8005ea2c361f026cec557fa1c6 /object.c
parente8010c7401764f54173ffbe8c2bde38cd6d216fa (diff)
downloadruby-f3a0d7a2035e9f5e0c70effd55732607e3def263.tar.gz
Rewrite Kernel#tap with Ruby (#3281)
* Rewrite Kernel#tap with Ruby This was good for VM too, but of course my intention is to unblock JIT's inlining of a block over yield (inlining invokeyield has not been committed though). * Fix test_settracefunc About the :tap deletions, the :tap events are actually traced (we already have a TracePoint test for builtin methods), but it's filtered out by tp.path == "xyzzy" (it became "<internal:kernel>"). We could trace tp.path == "<internal:kernel>" cases too, but the lineno is impacted by kernel.rb changes and I didn't want to make it fragile for kernel.rb lineno changes.
Diffstat (limited to 'object.c')
-rw-r--r--object.c26
1 files changed, 0 insertions, 26 deletions
diff --git a/object.c b/object.c
index c4a0d3c7ee..4718fad66f 100644
--- a/object.c
+++ b/object.c
@@ -938,31 +938,6 @@ rb_class_search_ancestor(VALUE cl, VALUE c)
return class_search_ancestor(cl, RCLASS_ORIGIN(c));
}
-/**
- * call-seq:
- * obj.tap {|x| block } -> obj
- *
- * Yields self to the block, and then returns self.
- * The primary purpose of this method is to "tap into" a method chain,
- * in order to perform operations on intermediate results within the chain.
- *
- * (1..10) .tap {|x| puts "original: #{x}" }
- * .to_a .tap {|x| puts "array: #{x}" }
- * .select {|x| x.even? } .tap {|x| puts "evens: #{x}" }
- * .map {|x| x*x } .tap {|x| puts "squares: #{x}" }
- *
- *--
- * \private
- *++
- */
-
-VALUE
-rb_obj_tap(VALUE obj)
-{
- rb_yield(obj);
- return obj;
-}
-
/*
* Document-method: inherited
@@ -4638,7 +4613,6 @@ InitVM_Object(void)
rb_define_method(rb_mKernel, "instance_of?", rb_obj_is_instance_of, 1);
rb_define_method(rb_mKernel, "kind_of?", rb_obj_is_kind_of, 1);
rb_define_method(rb_mKernel, "is_a?", rb_obj_is_kind_of, 1);
- rb_define_method(rb_mKernel, "tap", rb_obj_tap, 0);
rb_define_global_function("sprintf", f_sprintf, -1);
rb_define_global_function("format", f_sprintf, -1);