There is a implicit expectation that we can emulate block accept call with begin/ensure like:
open do
...
end
#=> same as:
begin
open
yield
ensure
close
end
However, this proposal breaks this expectation. So I reject this ticket.
I try to consider to introduce how to filter the probes, like:
trace = TracePoint.new(:line, thread: Thread.current){ ... }
trace.enable #=> only enable on the current thread.
trace = TracePoint.new(:line, file: __FILE__){ ... }
trace.enable #=> only enable on this file.
trace = TracePoint.new(:line, method: method(:foo)){ ... }
trace.enable #=> only enable on `foo` method.
Is it because trace.enable { code } does not behave like
begin; trace.enable; code; ensure; trace.disable; end ?
If so, I think this problem could be avoided by just changing the name to imply "thread-local",
such as trace.enable_for_current_thread { code } or
trace.enable_in_block { code }.
However, this proposal breaks this expectation.
Could you explain it?
Is it because trace.enable { code } does not behave like
begin; trace.enable; code; ensure; trace.disable; end ?
Yes.
If so, I think this problem could be avoided by just changing the name to imply "thread-local",
such as trace.enable_for_current_thread { code } or
trace.enable_in_block { code }.
Yes.
This is what
I try to consider to introduce how to filter the probes, like:
Considerations about introducing "thread-lcoal" enable:
(1) POSITIVE: because it may be common use case to enable.
(2) NEGATIVE:
(2-1) because enable_xxx seems verbose.
(2-2) because we will want to introduce similar method to
limit file name or method name, like enable_file do ... end
(this is why I proposed keyword arg)