comp.lang.ada
 help / color / mirror / Atom feed
From: dvdeug@x8b4e53cd.dhcp.okstate.edu (David Starner)
Subject: Re: How to implement a continue statement in Ada?
Date: 2000/02/09
Date: 2000-02-09T00:00:00+00:00	[thread overview]
Message-ID: <87s8s3$aai1@news.cis.okstate.edu> (raw)
In-Reply-To: m3ya8v1g93.fsf@skinner.demon.co.uk

On 08 Feb 2000 22:28:08 +0000, Aidan Skinner <aidan@skinner.demon.co.uk> wrote:
>dvdeug@x8b4e53cd.dhcp.okstate.edu (David Starner) writes:
>
>> I disagree with that rule. The goto statement is the most
>> powerful control structure, and judiciously used, is 
>> very useful. My most recent use of a goto was to emulate
>> tail recursion. Does that mean that Ada needs a tail
>
>I would expect this case to be picked up by the compiler, without the
>need for an explicit goto. Was there a reason why the appropriate
>section of code couldn't be put into a (possibly nested) procedure and 
>recurse itself?

The code was part of a lexer, and looked like

function lexer return token is begin
<<label>>
-- Bookkeeping
if char(1) = '*' then
-- Deal with it
elsif char(1) = ''' then
...
elsif char (1) = '(' and char (2) = '*' then
   -- Eat the comment
   either goto label or return lexer;
elsif char (1) =  '%' then
...

GNAT didn't recognize it as tail recursion, so the non-recursive
version performed better with certain (pathological) code. I'd
be surprised to find that any Ada compiler did much better on
tail recursion than GNAT, as it's not important for most Ada
programs.

-- 
David Starner - dstarner98@aasaa.ofe.org
Only a nerd would worry about wrong parentheses with
square brackets. But that's what mathematicians are.
   -- Dr. Burchard, math professor at OSU




  parent reply	other threads:[~2000-02-09  0:00 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-08  0:00 How to implement a continue statement in Ada? Oliver Kellogg
2000-02-08  0:00 ` Ted Dennison
2000-02-09  0:00   ` Roger Barnett
2000-02-08  0:00 ` David Starner
2000-02-08  0:00   ` Aidan Skinner
2000-02-09  0:00     ` Ted Dennison
2000-02-12  0:00       ` Jeff Carter
2000-02-14  0:00       ` Oliver Kellogg
2000-02-09  0:00     ` David Starner [this message]
2000-02-10  0:00       ` Aidan Skinner
2000-02-12  0:00       ` Character vs. String comparisons (was: Re: How to implement a continue statement in Ada?) Jeff Carter
2000-02-12  0:00         ` David Starner
     [not found] <35EA8153.7BFC91E3@physics.purdue.edu>
1998-08-31  0:00 ` How to implement a continue statement in Ada? Norman H. Cohen
1998-08-31  0:00 ` Robert I. Eachus
1998-08-31  0:00   ` Robert T. Sagris
1998-09-01  0:00     ` Matthew Heaney
1998-09-01  0:00 ` alan walkington
1998-09-02  0:00   ` Dr Richard A. O'Keefe
1998-09-02  0:00     ` alan walkington
1998-09-02  0:00     ` Matthew Heaney
1998-09-03  0:00     ` dewarr
  -- strict thread matches above, loose matches on Subject: below --
1998-08-31  0:00 Robert T. Sagris
1998-09-01  0:00 ` Dr Richard A. O'Keefe
1998-09-01  0:00   ` dewarr
1998-09-03  0:00     ` Dr Richard A. O'Keefe
1998-09-03  0:00       ` dennison
1998-09-01  0:00 ` dewarr
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox