From: "Florian Groß" Date: 2005-09-11T01:36:26+09:00 Subject: Re: quick print type debugging Eric Mahurin wrote: > I just took a peek at your code. This could be quite slow > because it uses Binding#of_caller (searches stack, uses > continuations) and eval. I don't particularly like the idea of > putting code in a string (editors treat it like a string rather > than code). Oh, and having this debug/trace method return the > expression value would be very useful. Why do you think that this is too slow? It's something that only happens when debugging. Putting the string into a block doesn't help at all because strings are generated at parse-time so you avoid no overhead at all. True, getting the caller's binding isn't exactly fast, but it only happens when debugging. I think you are overrating this as you can make trace() a noop when $DEBUG is false. (Just like I do with assert { } in ruby-breakpoint.) I'm pretty sure that Proc#source is way slower than the Binding.of_caller solution, by the way.