Syntactic Confectionery Delight | |
PerlMonks |
Re^7: What perl operations will consume C stack space?by hv (Prior) |
on Feb 27, 2006 at 18:53 UTC ( [id://533114]=note: print w/replies, xml ) | Need Help?? |
The intention is to remove the C-stack recursion altogether and use perl's dynamic stacks instead. But that involves quite major surgery to the regexp engine, and I don't know when it is likely to happen. It does make me wonder whether repetition counts, at least in these fairly simple cases, couldn't be fulfilled with by a tail recursive routine to alleviate the stack growth? I don't know how you'd implement it to be tail recursive, but feel free to have a go. I suspect you'd need a quite different matching algorithm, in which case you'd probably end up needing rather more surgery than the current plan. If not, isn't there some scope for putting a check of the form die 'Not enough stack' if reps > stacksize / 792? As far as I know the stacksize isn't available within the perl process at the moment (nor more relevantly the current free stack space), and the cost per iteration may go up or down (depending on the build). If those numbers can be made available then yes, it would be a good idea to put a check in, probably by treating REG_INFTY as min(32766, freestack/stackcost). Hugo
In Section
Seekers of Perl Wisdom
|
|