From: "Guy N. Hurst" Date: 2001-06-22T07:41:54+09:00 Subject: [ruby-talk:16730] Re: Simulating call-by-reference in Ruby Tobin Baker wrote: > ... > The problem is that there doesn't seem to be any way to access the > caller's context without cooperation from the caller, e.g., having > them pass a Binding object as a parameter to the method they're > calling. I noticed on ruby-talk that some other people had struggled > with this problem as well. I had hoped at first that caller() might > give me what I was looking for, but of course it just returns a stack > trace, not a Binding object. Wouldn't it be useful to have a way for > any method to access its caller's context? I agree with you here. It would be nice to have some means to access the caller's binding without the caller having to explicitly pass it. Now, if you know the caller is in the top level, you can always use TOPLEVEL_BINDING. Also, you *can* get the caller's binding by using set_trace_func, fork, and IPC, as shown by matju some time ago when he needed $_ from the caller in [http://ruby-talk.com/12422]. But why have to go through such expensive an extreme measures? > Is anyone considering this > as an addition to Ruby 1.7, or are there insurmountable implementation > difficulties? Maybe we just need a name for it? How about #caller_binding? Matz? Guy N. Hurst -- HurstLinks Web Development http://www.hurstlinks.com/ Norfolk, VA 23510 (757)623-9688 FAX 623-0433 PHP/MySQL - Ruby/Perl - HTML/Javascript