From: John Ky Date: 2008-12-03T12:51:52+09:00 Subject: Re: Stack level too deep ------=_Part_157478_7044121.1228276655309 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline By the way, I'm sure it's not infinite recursion. It's just the nature of my algorithm: class PlaybackBase def record(&block) return PlaybackChain.new(self, block) end end class PlaybackNil < PlaybackBase def initialize(root) @root = root end def play_back(&block) block.call(@root) end end class PlaybackChain < PlaybackBase def initialize(tail, block) @tail = tail @block = block end def play_back(&block) @block.call(proc { @tail.play_back(&block) }) end end And it's better that I use the system stack rather than my own because it preserves nice behaviours with blocks $array1 = [1, 2, 3] $array2 = ['a', 'b', 'c'] $tail = PlaybackNil.new(nil) $tail = $tail.record do |block| $array1.each do |value| $value1 = value block.call end end $tail = $tail.record do |block| $array2.each do |value| $value2 = value block.call end end $tail.play_back do puts "#{$value1}, #{$value2}" end Above prints 1, a 2, a 3, a 1, b 2, b 3, b 1, c 2, c 3, c I build long playback chains like this to replay different combinations of things. -John On Wed, Dec 3, 2008 at 2:39 PM, John Ky wrote: > Hi, > > Is there any way for me to increase the stack size? My stack is huge: > > playback.rb:38:in `play_back': stack level too deep (SystemStackError) > > Cheers, > > -John > > ------=_Part_157478_7044121.1228276655309--