From: "zzak (Zachary Scott)" Date: 2012-12-06T04:56:11+09:00 Subject: [ruby-core:50595] [ruby-trunk - Bug #7513] TracePoint#enable/disable should not cause error Issue #7513 has been updated by zzak (Zachary Scott). =begin Hi Koichi-san, For boolean call-seq, I like: trace.enable -> true or false Re: calling event hooks within enable/disable block. I mean here: (({trace.enable { p trace.lineno } #=> RuntimeError: access from outside})) =end ---------------------------------------- Bug #7513: TracePoint#enable/disable should not cause error https://bugs.ruby-lang.org/issues/7513#change-34436 Author: ko1 (Koichi Sasada) Status: Open Priority: Normal Assignee: ko1 (Koichi Sasada) Category: core Target version: 2.0.0 ruby -v: ruby 2.0.0dev (2012-12-01 trunk 38127) [i386-mswin32_100] =begin = Abstract TracePoint#enable/disable should not cause error if it is enabled or disabled. = Problem The following code cause error because it calls "enable" on enabled tracepoint. trace = TracePoint.trace{} p trace.enabled? #=> true trace.enable #=> `enable': trace is already enable (RuntimeError) However, similar feature "GC.enable" and "GC.disable" don't cause error. They only return previous status. = Solution TracePoint#enable and disable should align GC.enable/disable. trace = TracePoint.trace{} # enable trace.enable # do nothing, and return true (enabled) trace.enable{ ... } # after block, trace is still enable Any comments? =end -- http://bugs.ruby-lang.org/