On 2006-07-22, Morton Goldberg <m_goldberg / ameritech.net> wrote:
> Thanks, I think I understand now. And I agree that having access to  
> the local variables of the try block is a Really Good Thing.
>
> But don't you think it would be clearer if you called the accessor  
> "block" rather than "binding". After all, its a Proc object not a  
> Binding object that's returned by err.binding. To actually get at the  
> value of the block variable, one has to apply Proc#binding to what  
> err.binding returns, giving err.binding.binding, which I find  
> somewhat confusing. I think code using your continuable exception  
> would read better with err.block.binding. See modified code below.


Well, you don't have to write err.binding.binding, because a proc
can be used as a binding as-is:

  def foo &bl
    eval "x", bl
  end
  
  x = 5
  
  foo {} ==> 5

Yet it's true that a proc has more in it than a binding, moreover we can make
use of this extra in the context of continuable exceptions -- eg., after
some kind of sanitization we might retry the "try" guarded action by
calling the block. That wouldn't happen if we just continued from the
error.

So, yes, eventually I argree that it's better to call that block
"block".

Regards,
Csaba