From: Paul Brannan Date: 2008-04-08T02:34:37+09:00 Subject: Re: Lisper says to rubyist: gimmie your syntax tree Tracer doesn't inject "trace statements" into the AST. It calls set_trace_func, so there's a callback for every event (method call, method return, new line, etc.). The performance bottleneck of Tracer is that one of the arguments to the trace function is a binding; creating this binding is an expensive operation. AFAIK the only way to avoid this is to use the C API to call rb_add_event_hook instead of using set_trace_func from Ruby. This is what the ruby-debug gem does, e.g.: rdebug --trace test.rb As for your idea of dynamically modifying program structure at run-time, I've toyed with this idea, but it's not trivial. The biggest hurdle is Ruby's handling of local/dynamic variables. IMO the AST is too low-level a program representation to be used for this. An intermediate representation that abstracts away some of the details of the AST is I think what's needed. Paul