From: Paul Brannan Date: 2004-11-30T00:10:17+09:00 Subject: Re: RFE: Kernel#set_trace_func On Sun, Nov 28, 2004 at 08:26:06AM +0900, Florian Gro� wrote: > Moin! > > Would it be possible to let set_trace_func() return the trace func that > was set before the current one gets stored? This would be very useful > when you have a temporary trace func that will go away quickly. I'd find > this particularly useful for letting Binding.of_caller and Tracer > coexist peacefully, but I'm pretty sure there are a lot more use cases. This would introduce an incompatibility. set_trace_func currently returns the new trace func; I don't know if anyone relies on this behavior (seems unlikely, but possible). The problem is more general than your case; any time you want multiple trace funcs (e.g. running the profiler and tracer together), it's useful to get the old trace func. This is why I proposed the trace_func accessor in RCR#196; it doesn't have the incompatibility mentioned above, but still allows multiple trace_funcs. Matz's complaint, though, was that chaining is ugly (and I agree; how do you remove a trace func from the middle of the chain?). Another solution is to have set_trace_func return an id that can be used to later remove the trace func via a call to remove_trace_func. It's possible to implement this entirely in ruby, if you really need it. This still breaks backward-compatibility, though. I like the idea some anonymous RCR user suggested of having a well-defined API for all of ruby's hooks. I don't know what this API would look like, though, or I would suggest it. Paul