× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



The depth of recursion depends on the size of the procedure and the assigned workspace of the job by the system,I think.

I once tried this with a simple programme. It crashed at level 1065, IIRC. But this was a small test programme.

You should try for yourself how deep you can go. As Ken says, 4 levels is not that problematic.

Regards,
Carel Teijgeler


On 14-2-2013 22:24, Ken Sims wrote:
Hi Phil -

On Thu, 14 Feb 2013 13:50:08 -0500, ssc1478 <ssc1478@xxxxxxx> wrote:

I recently read this article:
http://ibmsystemsmag.com/ibmi/developer/rpg/rpgle_recursion/

and was interested in this comment:
"Even though this procedure doesn’t return a value, it’s a good idea to
have a return statement on the end so the program can exit right away after
it reaches the end of MGACCM. Otherwise, it will unwind itself by going
from the Endif line to the end of the procedure for as many records as were
written."

What I've noticed is that each recursive call puts an entry on the call
stack, and at the end it "unwinds" down the call stack until it can exit
the subprocedure. I thought the author's comment above was addressing
that, but it made no impact on my test pgm.

Is that the expected behavior? I'm worried about a long-running job
running into a system limit. Does anyone know?

If a procedure has no explicit RETURN, there is an implicit RETURN
when it hits the end of the procedure.

So as Rory said, it's not how many times a given procedure is called,
it's how many level of procedure calls (recursive or otherwise) are
active at any given moment.

It used to be 255 but that may have been increased. (I have some
actual recursive procedure calls but the data that I'm working with
normally only goes to around 4 levels so I've not concerned myself
with the actual limit.)

Ken
Opinions expressed are my own and do not necessarily represent the views
of my employer or anyone in their right mind.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.