Related articles |
---|
RE: Detecting endless recursion? qjackson@shaw.ca (Quinn Tyler Jackson) (2004-01-17) |
Re: Detecting endless recursion? lex@cc.gatech.edu (Lex Spoon) (2004-01-22) |
RE: Detecting endless recursion? qjackson@shaw.ca (Quinn Tyler Jackson) (2004-02-04) |
Re: Detecting endless recursion? cymric73@hotmail.com (Maarten D. de Jong) (2004-02-08) |
Re: Detecting endless recursion? witness@t-online.de (Uli Kusterer) (2004-02-13) |
Re: Detecting endless recursion? joachim.durchholz@web.de (Joachim Durchholz) (2004-02-26) |
Re: Detecting endless recursion? lex@cc.gatech.edu (Lex Spoon) (2004-02-26) |
From: | Quinn Tyler Jackson <qjackson@shaw.ca> |
Newsgroups: | comp.compilers |
Date: | 17 Jan 2004 23:23:04 -0500 |
Organization: | Compilers Central |
Keywords: | debug, practice |
Posted-Date: | 17 Jan 2004 23:23:04 EST |
In-reply-to: | 04-01-050 |
Uli Kusterer said:
> The best suggestion I've been able to get from some mailing lists was
> to just put a limit on the size of my pseudo-stack and when that is
> exceeded raise an error. This is very straightforward and would be
> easy to implement (and I feel stupid for not thinking of this), but I
> have no idea how to determine this limit.
I'm going to suggest something non-standard, but since this is a "language
for beginners" you might want to consider it.
Allow the programmer to define an event callback function that is called
when some function reaches the default limit of recursion on any given
function, and if that callback returns > 0 -- go deeper by up to that
amount. If it returns 0 -- terminate the program with a "recursion limit
exceeded" error.
My thinking is that this would allow beginning programmers to be notified
that they have entered a deep recursion scenario, at which point they will
have to make a conscious decision as to whether or not it is called for.
Another idea is to introduce a #pragma like syntax that allows a programmer
to specify the maximum recursion for any given function, if they wish to
exceed the built-in limit:
// assume the default depth is 1000
#pragma recursion_depth(10000) // override
int foo(int i)
{
if(i < 10000)
{
return foo(int i + 1);
}
return 0;
}
// pramga's scope ends with closing brace
--
Quinn Tyler Jackson
http://members.shaw.ca/qjackson/
Return to the
comp.compilers page.
Search the
comp.compilers archives again.