On Dec 9, 2005, at 7:39 AM, Steve Litt wrote:
> For awhile I was trying to get Node.pm to use two iterators with  
> blocks
> instead of the traditional callback routines (actually in addition  
> -- I want
> to keep all features in Node.pm and Node.py), but there's not a  
> yield_a and
> yield_b command, so I couldn't do it with both the entry and exit  
> callbacks,
> and having them each fire at the right time is vital.

Just capture the blocks into Proc objects and use Proc#call to invoke  
the block:

	def on_entry(&block)
	  @on_entry = block
	end

	def on_exit(&block)
	  @on_exit = block
         end

	def main
	   @on_entry && @on_entry.call( # entry args go here)
	   # do stuff
	   @on_exit && @on_exit.call( # exit args go here)
	end

Maybe this will give you some ideas.


Gary Wright