On Sep 28, 2004, at 10:29 AM, Florian Gross wrote:
> Gavin Kistner wrote:
>> So does "... trailing statements of method using it aren't in the 
>> block" mean "you can't place any statements after the 
>> Binding.of_caller invocation"? (Like it irrevocably changes the 
>> context and can't get you back to where you were or something?)
>
> [...]
> I tried to make the interface obvious in the documentation (see the 
> sample), but I seem to have failed. Do you have any suggestions for 
> how I could fix this?

Er, to which sample are you referring?

I think you could make it more clear by simply stating that 
Binding.of_caller must be in a method, and it must be the last 
statement in that method (but thanks to the magic of closures, you can 
put the rest of your code in the block).

I'd include this both in the documentation (worded like above) and also 
in the example, like:

def foo
	statement1
	statement2
	Binding.of_caller{ |binding|
		statement3_that_uses_binding
		statement4_that_clearly_uses_the_method_scope
	}
	# No other statements can go here!
end

- Gavin, who looks forward to a version of Ruby which has a simple 
"#caller" method that points to the instance which invoked the current 
method.