🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #4437

Re: GOTO controversy

#4437
From: Stephan A. Zdancewic
Date: Wed, 10 Apr 1996 14:18
37 lines
1527 bytes
a-cnadc@microsoft.com (Dann Corbit) writes:
> In article <3151B47F.70FD@connix.com>, shawley@connix.com says...
> >
> >What to you think? Loops without using loops?
> >
> >a loop:
> >
> >for(i=0;i<10;i++)
> >{
> >  stuff
> >}
> >
> >Looping with out a loop
> >
> >no_loop(0,10);
> >
> >no_loop(int start, int end)
> >{
> >    if(start != end) {
> >        stuff
> >        no_loop(start+1,end);
> >    }
> >}
> >
> >I haven't tested this but you get the idea.
> Yes, recursion can be used to loop "without a loop".
> There is no practical advantage to this method.
> The recursive version has 10 function calls to add
> to its overhead.

Actually, since this function is tail recursive, any good compiler
will optimize the recursive function call to a jump to the start of
the program block, effectively making this a loop.  Note that non-tail
recursive functions will not be subject to this optimization, however.

Steve Zdancewic
Carnegie Mellon University
Technical Details
Message-ID: <8lOwAOu00YUrQ7WHYl@andrew.cmu.edu>
Path: arc1-ca.pugleaf.net!andrew.cmu.edu!sz24+
References: <314FB5F5.259B@simi.is> <3151B47F.70FD@connix.com> <4jc1qa$lvv@news.microsoft.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!andrew.cmu.edu!sz24+
From: "Stephan A. Zdancewic" <sz24+@andrew.cmu.edu>
Newsgroups: comp.lang.misc,comp.lang.pl1,comp.lang.apl,comp.lang.c
Subject: Re: GOTO controversy
Date: Wed, 10 Apr 1996 10:18:02 -0400
Organization: Senior, Math/Computer Science, Carnegie Mellon, Pittsburgh, PA
Message-ID: <8lOwAOu00YUrQ7WHYl@andrew.cmu.edu>
References: <314FB5F5.259B@simi.is> <3151B47F.70FD@connix.com>
 <4jc1qa$lvv@news.microsoft.com>
NNTP-Posting-Host: po8.andrew.cmu.edu
In-Reply-To: <4jc1qa$lvv@news.microsoft.com>