Re: Recursive Call
- From: "Chuck Stevens" <charles.stevens@xxxxxxxxxx>
- Date: Fri, 4 Nov 2005 12:19:01 -0800
"Judson McClendon" <judmc@xxxxxxxxxxxxx> wrote in message
news:lNOaf.14$%k.4@xxxxxxxxxxxxxxxxxxxxxxxxx
> "Chuck Stevens" <charles.stevens@xxxxxxxxxx> wrote:
>> Note that within COBOL that is compliant with the three most recent
>> standards, both direct and indirect recursion is prohibited. If an
>> implementor allows it (or provides additional syntax to support it), it's
>> an extension and it does whatever the implementor says it does.
>
> Why in the world would recursion be forbidden? I haven't used it often in
> COBOL, but I did find it extremely useful in writing a parts explosion
> module once. The code, which was pretty elegant, would have been somewhat
> tacky without recursion.
While recursion isn't a big issue for stack-oriented machines like the
Unisys MCP systems -- on which the compiler has to go to the trouble to
generate code to *prevent* recursion -- I believe there was some reluctance
on the part of J4 to require it until it could be ascertained what the
pitfalls were and what the appropriate syntax was.
The initial specification of Inter-Program Communication was in '74 COBOL,
and my guess is the approach was "wait and see how it shakes out".
The *second* specification added nested programs, which was a significant
advancement, and again, enough syntax was added to raise the question as to
whether adding recursion would break something.
Since our systems fundamentally support recursion, and since it's a common
technique in ALGOL and related languages, I am led to suggest that the
technique must be used very carefully. The impact of a runaway loop in a
recursive environment can be significantly greater and can cause escalating
resource consumption in ways that an "ordinary" runaway loop wouldn't.
COBOL doesn't (yet) have a standardized mechanism for asynchronous
processing, either (our COBOL85 does, and I happen to think the syntax
involving USAGE EVENT and USAGE LOCK is clean and clear), and I think
similar issues occur there. It becomes the programmer's responsibility to
protect the data for each user in a multithreaded program, and the issues
there can easily get very sticky very quickly on efficiency, security, and
effectiveness grounds.
-Chuck Stevens
.
- Follow-Ups:
- Re: Recursive Call
- From: Joe Zitzelberger
- Re: Recursive Call
- From: Judson McClendon
- Re: Recursive Call
- References:
- Recursive Call
- From: Paolo
- Re: Recursive Call
- From: Chuck Stevens
- Re: Recursive Call
- From: Judson McClendon
- Recursive Call
- Prev by Date: Re: Newsgroup browsers
- Next by Date: Re: Cobol work?
- Previous by thread: Re: Recursive Call
- Next by thread: Re: Recursive Call
- Index(es):
Relevant Pages
|