From: ES Date: 2005-06-05T23:14:58+09:00 Subject: Re: unbinding a Proc? Le 5/6/2005, "Eric Mahurin" a �crit: >This is mostly a curiosity thing... > >Is there a way to unbind a Proc from the binding it was created >in? What I mean by this is taking a Proc and looking >up/calling everything it refers to outside of itself and >replacing them with what was found - objects. Assignments to >the outside and method calls that modify things on the outside >should be considered illegal. > >The application for doing this would be to get rid of many >*eval(string) calls which I think are evil because you are >parsing/recompiling code at run-time - a severe limitation to >optimization. I think many of the times that you use >*eval(string) instead of *eval(proc) (or Proc#call), you do so >because you take the values of certain variables and put it in >the string (with #{...}). You want these to be constant >instead of refer to these variables in your context all the >time. This effectively "unbinds" those variables from their >context. > >Another useful thing might be rebinding a Proc to a different >Binding. But, I can't think of any applications off-hand. Proc#rebind would be very useful but I am still waiting for a full-blown first-order method conversion, too. E -- template void quack(duck& d) { d.quack(); }