# \[ANN\] remembered\_evals 0.0.4 -- debugging help for eval

**URL:** <https://www.ruby-forum.com/t/ann-remembered-evals-0-0-4-debugging-help-for-eval/172303>\
**Category:** Ruby\
**Created:** [July 18, 2009, 11:49pm UTC](https://www.ruby-forum.com/t/ann-remembered-evals-0-0-4-debugging-help-for-eval/172303 "2009-07-18T23:49:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [July 18, 2009, 11:49pm UTC](https://www.ruby-forum.com/t/ann-remembered-evals-0-0-4-debugging-help-for-eval/172303/1 "2009-07-18T23:49:56Z")

</div>

Please to announce the release of remembered\_evals 0.0.4  
Wasn’t sure if anything like it existed, so wrote this gem.

remembered\_evals:

A library to make debugging eval’ed code possible.

This library monkey patches Kernel.\*eval to save eval’ed code to a cache  
file before evaluating it (files saved to  
~/.\_remembered\_evals/hash\_of\_that\_code).

You can thus debug [ex: using ruby-debug] THROUGH eval’ed code, now, as  
well as see appropriate (useful) eval’ed code lines in exception  
backtraces, instead of just eval(2) as the line number in the backtrace.

It also offers an additional tool for developers: Since it saves code  
by hash value, and doesn’t write over cached files, you can actually  
edit eval’ed blocks and it will eval the edited version–i.e. it allows  
you to override certain strings passed to eval [it uses yours instead of  
the original]-- quite useful for debugging purposes if you use  
meta-programming heavily.

[http://github.com/rogerdpack/ruby\_remembered\_evals/tree/master](http://github.com/rogerdpack/ruby_remembered_evals/tree/master)

Install:  
gem sources -a [http://gems.github.com](http://gems.github.com) # if necessary  
gem install rogerdpack-remembered\_evals # may need to precede with sudo

And enjoy the eval’ed code bliss.

Feedback welcome rogerdpack @ github

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [July 19, 2009, 11:00pm UTC](https://www.ruby-forum.com/t/ann-remembered-evals-0-0-4-debugging-help-for-eval/172303/2 "2009-07-19T23:00:16Z")

</div>

On 7/18/09, Roger P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Please to announce the release of remembered\_evals 0.0.4  
> Wasn’t sure if anything like it existed, so wrote this gem.
> 
> remembered\_evals:
> 
> A library to make debugging eval’ed code possible.
> 
> This library monkey patches Kernel.\*eval to save eval’ed code to a cache  
> file before evaluating it

I’ve used this same trick myself several times to be able to debug  
eval’d code. A library for it is nice. Let me make a suggestion, tho.  
You ought to name the method something other than eval, since your new  
implementation (unavoidably) changes the semantics of a  
well-established and much used builtin method. How about  
debuggable\_eval? Some kind of switch to have it fall back to the plain  
vanilla eval for production mode might be nice too.

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [July 20, 2009, 3:38pm UTC](https://www.ruby-forum.com/t/ann-remembered-evals-0-0-4-debugging-help-for-eval/172303/3 "2009-07-20T15:38:44Z")

</div>

> I’ve used this same trick myself several times to be able to debug  
> eval’d code. A library for it is nice. Let me make a suggestion, tho.  
> You ought to name the method something other than eval, since your new  
> implementation (unavoidably) changes the semantics of a  
> well-established and much used builtin method. How about  
> debuggable\_eval? Some kind of switch to have it fall back to the plain  
> vanilla eval for production mode might be nice too.

Yeah it turned out to be deftly useful at least once for me.

Currently when I want to use it for debugging, I’ll add this line  
require ‘remembered\_evals’  
or comment it out when I’m _not_ debugging.  
For me that feels explicit enough. Thoughts?  
=r
