Re: [RFC PATCH] explicitly mark recursion count

Linus Torvalds
2004-06-02T14:45:42Z

On Wed, 2 Jun 2004, Jörn Engel wrote:
>
> Then you see something I don't see. For example there are quite a few
> recursions with some function like
>
> void foo(int depth)
> {
> if (!depth) {
> bar(1);
> }
> ...
> }
>
> bar will, maybe through several more functions call foo(1).
>
> How can you say that foo will beak this recursion after two rounds
> max?

The programmer had _better_ know that there is some upper limit.

> I claim:
> There is no way to tell the depth of any recursion without looking at
> all involved functions.

And I claim: recursion is illegal unless the programmer has some explicit
recursion limiter. And if he has that recursion limiter in one of the
functions, then he damn well better know it, and know the value it limits
recursion to.

Linus