Alan Chen wrote:
> Hal Fulton wrote:
> 
>>On the one hand, I appreciate Ruby because I *can* do this
>>sort of thing. On the other hand, if the logic for #action
>>changes, how many pieces of code will I find myself modifying?
> 
> 
> Exactly, you *never* want to code yourself into a corner where one
> change in logic needs to be refelected in parallel branches -
> especially when
> your involving diagnostic code. DRY!
> 
> A different way to approach your problem is to have a smarter tracer
> object which performs a noop when its inactive.
> 
> def action
> @tracer.puts "Entering action"
> do_this
> @tracer.puts "Returned from do this"
> do_that
> @tracer.puts "Returned from do that"
> end

IIRC, you'll get better performance if you arrange the tracer so you can 
use it like:

def action
   trace { puts ... }
   do_this
   trace { puts ... }
   do_that
end

You avoid at least the ivar lookup.