Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Recursion error and line numbers



On Jun 18,  1:38pm, Peter Stephenson wrote:
} Subject: Re: Recursion error and line numbers
}
} On the two PCs I tried this on (neither particularly antiquated) it
} crashed, so the maximum function depth of 4096 isn't limited enough.

I have 3GB RAM + 6GB swap on my home machine now (total overkill for
most of what it does) so I'm probably not a good test case for this
kind of thing any more ...

} How about 1000?  That seems to stop it.

It looks as if it's been 4096 ever since we added it back in about
April 2000.  A default of 1000 is most likely OK, given that it's
configure-time settable.

What we need is something like perl's "goto &routine;" to implement a
tail-call optimization.  Of course, that just turns it into an infinite
loop.

} > Obviously the recursion depth isn't 1 or 10 or 50 either.  Where is that
} > number coming from?  I would have expected "1" in all cases.
} 
} It's a subtle effect of line number handling and I haven't quite worked
} out why yet.

Perhaps it has something to do with having left off the braces around
the function body?

Compare:

torch% deep() deep 
torch% deep
deep:2: maximum nested function level reached
torch% deep() { deep }
torch% deep
deep: maximum nested function level reached
torch% deep()         
function> deep
torch% deep
deep:7: maximum nested function level reached
torch% deep()
function> { deep }
torch% deep
deep:1: maximum nested function level reached

Note that without the braces, the line numbers seem to be counting the
number lines of input that have been read; the number must be coming in
from the surrounding scope.



Messages sorted by: Reverse Date, Date, Thread, Author