From: Paul Brannan Date: 2001-10-03T23:52:38+09:00 Subject: [ruby-talk:22010] Re: Backtrace with eval On Wed, 3 Oct 2001, ts wrote: > Now try (to see the difference) > > eval "bar", nil, "(eval)" Interesting, this is also the same (since "(eval)" is the default value for the third argument). However, eval "bar", nil, "eval" is different. eval seems to treat "(eval)" as a special case (eval.c, line 4912): if (strcmp(file, "(eval)") == 0) { if (ruby_sourceline > 1) { errat = get_backtrace(ruby_errinfo); err = RARRAY(errat)->ptr[0]; rb_str_cat2(err, ": "); rb_str_append(err, ruby_errinfo); } else { err = rb_str_dup(ruby_errinfo); } errat = Qnil; rb_exc_raise(rb_exc_new3(CLASS_OF(ruby_errinfo), err)); } I'm not sure what the ruby_sourceline stuff is (perhaps you could enlighten me?), but it seems that in the 'eval "bar", nil, "(eval)"' case, the interpreter is only grabbing the line that the exception came from, and using that in the exception string (rather than throwing a new exception with the same backtrace plus the current calls stack). Generally speaking, it is a bad idea to have undocumented special cases like this. Does Ruby have a rationale for doing this that I am not aware of? Paul