comp.lang.ada
 help / color / mirror / Atom feed
* Local vs global variables in ADA
@ 2002-11-03 18:17 Roger
  2002-11-03 19:03 ` Per Sandbergs
                   ` (3 more replies)
  0 siblings, 4 replies; 37+ messages in thread
From: Roger @ 2002-11-03 18:17 UTC (permalink / raw)


Yes I'm an Ada newbie and have a questions about local and global variables.
When exactly is a variable said to be global?

for example I have this code
--main procedure
Procedure Main Is
--If I declare a variable here will it be considered as
--global to the sub procedures?


--sub procedure
Procedure Sub

Begin

End Sub;



Begin
--If I declare a variable here will it be considered as
--global to the sub procedure?
End Main;





any help is appreciated.





^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-03 18:17 Local vs global variables in ADA Roger
@ 2002-11-03 19:03 ` Per Sandbergs
  2002-11-03 19:31 ` Eric Jacoboni
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 37+ messages in thread
From: Per Sandbergs @ 2002-11-03 19:03 UTC (permalink / raw)


First Read the Ada manual:
Then on uour specific question
It is a mater of scope so have a look at the folowing:

procedure main is
    V_main_1 : integer := 0;

    procedure s1 is
        v_s1_1 : integer := 0;
   begin
        null; -- V_main_1 and V_s1_1 is vissible here;
    end;

begin --main
    declare
        V_Main_2 : integer := 0;
    begin
        null; -- V_main_1, V_main_2 and V_s1_1 is vissible here;
    end;
    --     V_main_1 is vissible here;
end main;
So think of it as a tree wher the main trunk is the "main" procedure and all
branches will see back towards the main trunk
but not other branches.

/Per Sandberg

"Roger" <in@yourdreams.com> wrote in message
news:5Ldx9.3695$151.38236@weber.videotron.net...
> Yes I'm an Ada newbie and have a questions about local and global
variables.
> When exactly is a variable said to be global?
>
> for example I have this code
> --main procedure
> Procedure Main Is
> --If I declare a variable here will it be considered as
> --global to the sub procedures?
>
>
> --sub procedure
> Procedure Sub
>
> Begin
>
> End Sub;
>
>
>
> Begin
> --If I declare a variable here will it be considered as
> --global to the sub procedure?
> End Main;
>
>
>
>
>
> any help is appreciated.
>
>





^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-03 18:17 Local vs global variables in ADA Roger
  2002-11-03 19:03 ` Per Sandbergs
@ 2002-11-03 19:31 ` Eric Jacoboni
  2002-11-04  1:47 ` Jeffrey Carter
  2002-11-04 13:47 ` Martin Dowie
  3 siblings, 0 replies; 37+ messages in thread
From: Eric Jacoboni @ 2002-11-03 19:31 UTC (permalink / raw)


>>>>> "Roger" == Roger  <in@yourdreams.com> writes:

Roger> Procedure Main Is
Roger> --If I declare a variable here will it be considered as
Roger> --global to the sub procedures?

Yes.

Roger> Begin
Roger> --If I declare a variable here will it be considered as
Roger> --global to the sub procedure?

The point is that you can't declare anything after a begin... (you may
open a declare block, but the scope of variables declared in it is
limited to this block).


-- 
�ric Jacoboni, n� il y a 1339791698 secondes



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-03 18:17 Local vs global variables in ADA Roger
  2002-11-03 19:03 ` Per Sandbergs
  2002-11-03 19:31 ` Eric Jacoboni
@ 2002-11-04  1:47 ` Jeffrey Carter
  2002-11-04 13:27   ` Wes Groleau
  2002-11-04 13:47 ` Martin Dowie
  3 siblings, 1 reply; 37+ messages in thread
From: Jeffrey Carter @ 2002-11-04  1:47 UTC (permalink / raw)


Roger wrote:
> Yes I'm an Ada newbie and have a questions about local and global variables.
> When exactly is a variable said to be global?

This is a good question. Unlike some languages, in which a variable is 
either global or local, Ada has various degrees of locality. This 
sometimes causes heated discussions between those who follow a strict, 
blind-obedience rule of no global variables and those with a better 
understanding of the matter.

For example, a variable declared in a package body may be global to the 
subprograms in the package, but they are not visible outside the 
package. Knee-jerk rule following says these are not allowed because 
they're global variables. Actually, these are state variables for the 
package and perfectly acceptable.

The only real global variables in Ada are those declared in the visible 
part of package specifications. These are a no-no.

> 
> for example I have this code
> --main procedure
> Procedure Main Is
> --If I declare a variable here will it be considered as
> --global to the sub procedures?

Yes.

> --sub procedure
> Procedure Sub
> 
> Begin
> 
> End Sub;
> 
> 
> 
> Begin
> --If I declare a variable here will it be considered as
> --global to the sub procedure?
> End Main;

You can't declare a variable there without a block statement. Perhaps 
you meant

begin -- Main
    declare
       -- variable declaration
    begin
       ...
    end;
end Main;

in which case you can have declarations there. Such declarations are not 
visible outside the block statement in which they are declared, so they 
are not visible to Sub.

Not that Ada is not C, so your main procedure can have a more 
informative name than "Main" if you like.

-- 
Jeff Carter
"Monsieur Arthur King, who has the brain of a duck, you know."
Monty Python & the Holy Grail




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-04  1:47 ` Jeffrey Carter
@ 2002-11-04 13:27   ` Wes Groleau
  2002-11-04 20:48     ` Jeffrey Carter
  0 siblings, 1 reply; 37+ messages in thread
From: Wes Groleau @ 2002-11-04 13:27 UTC (permalink / raw)


> The only real global variables in Ada are those declared in the visible 
> part of package specifications. These are a no-no.

Generally a bad idea.  However, it's worth noting that
a large number of very smart people saw no reason to
make them illegal when the language was being designed.




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-03 18:17 Local vs global variables in ADA Roger
                   ` (2 preceding siblings ...)
  2002-11-04  1:47 ` Jeffrey Carter
@ 2002-11-04 13:47 ` Martin Dowie
  3 siblings, 0 replies; 37+ messages in thread
From: Martin Dowie @ 2002-11-04 13:47 UTC (permalink / raw)


"Roger" <in@yourdreams.com> wrote in message news:<5Ldx9.3695$151.38236@weber.videotron.net>...
> Yes I'm an Ada newbie and have a questions about local and global variables.
> When exactly is a variable said to be global?

I don't consider Ada to have global variables when used normally (at least
not in the COBOL sense I was brought up with), as even a data item declared
in a package specification, it is still local to that package - as in, you
still have to reference the package name somewhere before using the data
item.

The exception to this is "pragma Export" and "pragma Import". With these
you can do hideously dangerous things and completely remove the need for
context clauses! :-)

e.g.

package body Foo is
   ...
   My_Local : Integer;
   pragma Export (Ada, My_Local, "My_Local");
   ...
end Foo;

...

-- WITHOUT "with Foo;"
--
package body Bar is
   ...
   -- No idea where "My_Local" is actual declared!
   --
   My_Other_Local : Integer;
   pragma Import (Ada, My_Other_Local, "My_Local");
   ...
end Bar;



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-04 13:27   ` Wes Groleau
@ 2002-11-04 20:48     ` Jeffrey Carter
  2002-11-05  8:43       ` Fraser Wilson
  0 siblings, 1 reply; 37+ messages in thread
From: Jeffrey Carter @ 2002-11-04 20:48 UTC (permalink / raw)


Wes Groleau wrote:
>> The only real global variables in Ada are those declared in the 
>> visible part of package specifications. These are a no-no.
> 
> 
> Generally a bad idea.  However, it's worth noting that
> a large number of very smart people saw no reason to
> make them illegal when the language was being designed.

True. But since at the Ada launch on 1980 Dec 10, some of those people 
said that the language contained "goto" primarily to facilitate 
automated translation from languages such as FORTRAN 66, and "while" 
primarily to facilitate such translation from languages such as Pascal, 
we should not construe that everything allowed by the language is 
necessarily a Good Idea for new software.

-- 
Jeff Carter
"Monsieur Arthur King, who has the brain of a duck, you know."
Monty Python & the Holy Grail




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
@ 2002-11-05  6:42 Grein, Christoph
  2002-11-05 15:59 ` Martin Dowie
  0 siblings, 1 reply; 37+ messages in thread
From: Grein, Christoph @ 2002-11-05  6:42 UTC (permalink / raw)


Martin Dowie:
> The exception to this is "pragma Export" and "pragma Import". With these
> you can do  dangerous things and completely remove the need for
> context clauses! :-)
> 
> e.g.
> 
> package body Foo is
>    ...
>    My_Local : Integer;
>    pragma Export (Ada, My_Local, "My_Local");
>    ...
> end Foo;
> 
> ...
> 
> -- WITHOUT "with Foo;"
> --
> package body Bar is
>    ...
>    -- No idea where "My_Local" is actual declared!
>    --
>    My_Other_Local : Integer;   <-- could be any type here (if the size
                                     matches; if not, you'll suffer from
                                     nasal demons...)
>    pragma Import (Ada, My_Other_Local, "My_Local");
>    ...
> end Bar;

and they need not even be of the same type. You can completely undermine the Ada 
type concept with this.

As Martin said: it's "hideous"



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-04 20:48     ` Jeffrey Carter
@ 2002-11-05  8:43       ` Fraser Wilson
  2002-11-05 13:53         ` Charles H. Sampson
                           ` (2 more replies)
  0 siblings, 3 replies; 37+ messages in thread
From: Fraser Wilson @ 2002-11-05  8:43 UTC (permalink / raw)


Jeffrey Carter <jrcarter@acm.org> writes:

> True. But since at the Ada launch on 1980 Dec 10, some of those people 
> said that the language contained "goto" primarily to facilitate 
> automated translation from languages such as FORTRAN 66, and "while" 
> primarily to facilitate such translation from languages such as Pascal, 

On the "while" comment: are you (or were they) referring to the fact
that a while loop can be expressed as a loop/exit when/end loop
construction, or is there something about while loops that should be
avoided?  Isn't there a preference hierarchy from for loop to while
loop to loop?  I.e. use a for loop whenever possible, failing that a
while loop, and as a last resort a loop with an exit.  OK, and as a
last last resort use a goto.

Fraser.



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-05  8:43       ` Fraser Wilson
@ 2002-11-05 13:53         ` Charles H. Sampson
  2002-11-06  4:59           ` R. Tim Coslet
  2002-11-05 17:28         ` Stephen Leake
  2002-11-05 19:54         ` Jeffrey Carter
  2 siblings, 1 reply; 37+ messages in thread
From: Charles H. Sampson @ 2002-11-05 13:53 UTC (permalink / raw)


Fraser Wilson <newsfraser@blancolioni.org> wrote:

> Jeffrey Carter <jrcarter@acm.org> writes:
> 
> > True. But since at the Ada launch on 1980 Dec 10, some of those people
> > said that the language contained "goto" primarily to facilitate 
> > automated translation from languages such as FORTRAN 66, and "while"
> > primarily to facilitate such translation from languages such as Pascal,
> 
> On the "while" comment: are you (or were they) referring to the fact
> that a while loop can be expressed as a loop/exit when/end loop
> construction, or is there something about while loops that should be
> avoided?  Isn't there a preference hierarchy from for loop to while
> loop to loop?  I.e. use a for loop whenever possible, failing that a
> while loop, and as a last resort a loop with an exit.  OK, and as a
> last last resort use a goto.
> 
> Fraser.

     I don't know what the "founders" intended but how's this for a
rule: Use a for-loop only when it's appropriate, use a while-loop only
when it's appropriate, use an "infinite" loop in all other cases. :-)

     Seriously, here's what I try to do: use the for-loop and while-loop
only when they express the loop's termination condition.  In other
words, do not use exit statements within loops of these forms; if a loop
requires an exit statement, then use an "infinite" loop instead.
Unfortunately, my will power is often too weak to overcome the
convenience of the automatically declared counting variable of a
for-loop.  I'm much better with while loops.

                                Charlie

-- 
     For an email response, my real user name is csampson and my ISP is
inetworld.net.



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-05  6:42 Grein, Christoph
@ 2002-11-05 15:59 ` Martin Dowie
  0 siblings, 0 replies; 37+ messages in thread
From: Martin Dowie @ 2002-11-05 15:59 UTC (permalink / raw)


"Grein, Christoph" <christoph.grein@eurocopter.com> wrote in message
news:mailman.1036478942.5653.comp.lang.ada@ada.eu.org...
> Martin Dowie:
> and they need not even be of the same type. You can completely undermine
the Ada
> type concept with this.

Wow! I've never tried anything _that_ dangerous before!!!





^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-05  8:43       ` Fraser Wilson
  2002-11-05 13:53         ` Charles H. Sampson
@ 2002-11-05 17:28         ` Stephen Leake
  2002-11-05 17:38           ` Jean-Pierre Rosen
  2002-11-05 22:37           ` Robert A Duff
  2002-11-05 19:54         ` Jeffrey Carter
  2 siblings, 2 replies; 37+ messages in thread
From: Stephen Leake @ 2002-11-05 17:28 UTC (permalink / raw)


Fraser Wilson <newsfraser@blancolioni.org> writes:

> ...  Isn't there a preference hierarchy from for loop to while
> loop to loop?  I.e. use a for loop whenever possible, failing that a
> while loop, and as a last resort a loop with an exit.  OK, and as a
> last last resort use a goto.

In my style guide, I use a for loop _only_ if the loop will _always_
be executed exactly as indicated in the "for" part. No other loop
exits allowed.

Otherwise, I use an "exit when" loop.

Never use a "while" loop. Mostly because "exit when" is much clearer,
partly because I've used other languages that had slightly different
definitions of "while", and I can't keep them straight.

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-05 17:28         ` Stephen Leake
@ 2002-11-05 17:38           ` Jean-Pierre Rosen
  2002-11-05 19:57             ` Jeffrey Carter
                               ` (2 more replies)
  2002-11-05 22:37           ` Robert A Duff
  1 sibling, 3 replies; 37+ messages in thread
From: Jean-Pierre Rosen @ 2002-11-05 17:38 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1239 bytes --]


"Stephen Leake" <stephen.a.leake.1@gsfc.nasa.gov> a �crit dans le message
news: u3cqg9b8l.fsf@gsfc.nasa.gov...
> Fraser Wilson <newsfraser@blancolioni.org> writes:
>
> > ...  Isn't there a preference hierarchy from for loop to while
> > loop to loop?  I.e. use a for loop whenever possible, failing that a
> > while loop, and as a last resort a loop with an exit.  OK, and as a
> > last last resort use a goto.
>
> In my style guide, I use a for loop _only_ if the loop will _always_
> be executed exactly as indicated in the "for" part. No other loop
> exits allowed.
>
I beg to differ.
A for loop preserves you from a number of problem, especially when dealing
with limit cases.
Try to write a loop that does *exactly* what for does, and you'll see that
there are lots of benefits in using for.
For example, I always use a for in a search loop, which exits when the
element is found.

In Pascal, a for loop was always done entirely; you have to be aware that
Ada is different in that respect, but that does not mean that you should not
use a more powerful construct when you can.

--
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr





^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-05  8:43       ` Fraser Wilson
  2002-11-05 13:53         ` Charles H. Sampson
  2002-11-05 17:28         ` Stephen Leake
@ 2002-11-05 19:54         ` Jeffrey Carter
  2 siblings, 0 replies; 37+ messages in thread
From: Jeffrey Carter @ 2002-11-05 19:54 UTC (permalink / raw)


Fraser Wilson wrote:
> 
> On the "while" comment: are you (or were they) referring to the fact
> that a while loop can be expressed as a loop/exit when/end loop
> construction, or is there something about while loops that should be
> avoided?  Isn't there a preference hierarchy from for loop to while
> loop to loop?  I.e. use a for loop whenever possible, failing that a
> while loop, and as a last resort a loop with an exit.  OK, and as a
> last last resort use a goto.

The point made by Ichbiah, Barnes, and Firth at the Ada Launch was that 
while loops express the condition for continuation, not exit, and this 
is difficult for beginners to understand, and they usually require the 
use of negative logic (while not End_Of_File), which is often more 
difficult to understand than positive logic; that a loop with an exit as 
its first statement expresses the condition for exit, and this is easy 
for everyone to understand, and it usually uses positive logic (exit 
when End_Of_File). For these reasons they thought the latter form should 
be prefered.

There are as many preference hierarchies as there are people creating 
preference hierarchies. Here's one: use assembler whenever possible, 
failing that use C, failing that use a C derivative, failing that use 
another language other than Ada, and use Ada when forced to at gunpoint. 
I don't happen to agree with it, but I suspect that there are those who 
do. Just because you've seen someone's preference hierarchy doesn't mean 
you should follow it.

I use the rule that you should use the appropriate form of a loop for 
the iteration that's required. If you accept the arguments of "the 
founders", while is never the appropriate form.

-- 
Jeff Carter
"We burst our pimples at you."
Monty Python & the Holy Grail




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-05 17:38           ` Jean-Pierre Rosen
@ 2002-11-05 19:57             ` Jeffrey Carter
  2002-11-06  9:11               ` Jean-Pierre Rosen
  2002-11-05 20:26             ` Vinzent Hoefler
  2002-11-05 23:14             ` Wes Groleau
  2 siblings, 1 reply; 37+ messages in thread
From: Jeffrey Carter @ 2002-11-05 19:57 UTC (permalink / raw)


Jean-Pierre Rosen wrote:
> In Pascal, a for loop was always done entirely;

Barring a goto. Judicious use of gotos can sometimes make loops in 
Pascal much easier to read and understand.

-- 
Jeff Carter
"We burst our pimples at you."
Monty Python & the Holy Grail




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-05 17:38           ` Jean-Pierre Rosen
  2002-11-05 19:57             ` Jeffrey Carter
@ 2002-11-05 20:26             ` Vinzent Hoefler
  2002-11-05 23:14             ` Wes Groleau
  2 siblings, 0 replies; 37+ messages in thread
From: Vinzent Hoefler @ 2002-11-05 20:26 UTC (permalink / raw)


"Jean-Pierre Rosen" <rosen@adalog.fr> wrote:

>In Pascal, a for loop was always done entirely;

Don't know what the current standard says exactly, but modern Pascal
versions know a break-"instruction". Just to mention, doesn't matter.


Vinzent.




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-05 17:28         ` Stephen Leake
  2002-11-05 17:38           ` Jean-Pierre Rosen
@ 2002-11-05 22:37           ` Robert A Duff
  2002-11-05 23:46             ` Larry Hazel
                               ` (4 more replies)
  1 sibling, 5 replies; 37+ messages in thread
From: Robert A Duff @ 2002-11-05 22:37 UTC (permalink / raw)


Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov> writes:

> Never use a "while" loop. Mostly because "exit when" is much clearer,
> partly because I've used other languages that had slightly different
> definitions of "while", and I can't keep them straight.

Like what?  I mean, which languages have different definitions of
"while" loops, and what are the differences.  I thought "while" loops
were one of the few cases where there is pretty much agreement on the
semantics across languages.

I like while loops, and use them in favor of loop/exit whenever the exit
condition happens at the top.

I seem to recall some issue in SPARK, where they discouraged while
loops.  Something about wanting to put a loop-invariant before the exit
condition?  Maybe one of the SPARK folks can comment on that.  I'm happy
to write assertions that help program-proving tools, if they also help
me, the human reader (or at least neutral to the human reader), but I'm
a bit uncomfortable using a style that helps tools, but hinders humans.

- Bob



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-05 17:38           ` Jean-Pierre Rosen
  2002-11-05 19:57             ` Jeffrey Carter
  2002-11-05 20:26             ` Vinzent Hoefler
@ 2002-11-05 23:14             ` Wes Groleau
  2002-11-06  9:16               ` Jean-Pierre Rosen
  2 siblings, 1 reply; 37+ messages in thread
From: Wes Groleau @ 2002-11-05 23:14 UTC (permalink / raw)


Jean-Pierre Rosen wrote:
> In Pascal, a for loop was always done entirely; you have to be aware that

I'm not sure exactly what that means.  What French word
were you thinking of for "entirely" ?

Anyway, all the versions of Pascal I know of allow:

FOR     iter  DO     stmt

REPEAT  stmt  UNTIL  cond

WHILE   cond  DO     stmt




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-05 22:37           ` Robert A Duff
@ 2002-11-05 23:46             ` Larry Hazel
  2002-11-06  2:19               ` Dennis Lee Bieber
  2002-11-06  2:15             ` Dennis Lee Bieber
                               ` (3 subsequent siblings)
  4 siblings, 1 reply; 37+ messages in thread
From: Larry Hazel @ 2002-11-05 23:46 UTC (permalink / raw)


Robert A Duff wrote:
> Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov> writes:
> 
> 
>>Never use a "while" loop. Mostly because "exit when" is much clearer,
>>partly because I've used other languages that had slightly different
>>definitions of "while", and I can't keep them straight.
> 
> 
> Like what?  I mean, which languages have different definitions of
> "while" loops, and what are the differences.  I thought "while" loops
> were one of the few cases where there is pretty much agreement on the
> semantics across languages.
> 
If I remember correctly, the Fortran compiler for the SDS/Xerox Sigma computers 
used:

REPEAT
    Statements
WHILE Condition

or UNTIL Condition

Larry




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-05 22:37           ` Robert A Duff
  2002-11-05 23:46             ` Larry Hazel
@ 2002-11-06  2:15             ` Dennis Lee Bieber
  2002-11-06  7:04               ` Martin Dowie
  2002-11-06 14:40               ` john mann
  2002-11-06  7:18             ` Dale Stanbrough
                               ` (2 subsequent siblings)
  4 siblings, 2 replies; 37+ messages in thread
From: Dennis Lee Bieber @ 2002-11-06  2:15 UTC (permalink / raw)


Robert A Duff fed this fish to the penguins on Tuesday 05 November 2002 
02:37 pm:

> Like what?  I mean, which languages have different definitions of
> "while" loops, and what are the differences.  I thought "while" loops
> were one of the few cases where there is pretty much agreement on the
> semantics across languages.
>
        Well, it isn't a while, but...

        repeat
                ...
        until <cond>

which has the situation that it exits when <cond> goes true, whereas

        while <cond>
                ...
        wend

continues looping on a true <cond>.

        And /neither/ structure really handles the form where you need a bit 
of processing before you can do the test...


        loop
                preprocessing which sets flag
            exit when <cond>
                other processing
        end loop.

        Using just a while loop, as in many languages, the above turns into:

        (initial) preprocessing which may set flag
        while not flag
                other processing
                preprocessing which sets flag
        wend



--  
 > ============================================================== <
 >   wlfraed@ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
 >      wulfraed@dm.net     |       Bestiaria Support Staff       <
 > ============================================================== <
 >        Bestiaria Home Page: http://www.beastie.dm.net/         <
 >            Home Page: http://www.dm.net/~wulfraed/             <



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-05 23:46             ` Larry Hazel
@ 2002-11-06  2:19               ` Dennis Lee Bieber
  2002-11-06 13:45                 ` Dan Nagle
  0 siblings, 1 reply; 37+ messages in thread
From: Dennis Lee Bieber @ 2002-11-06  2:19 UTC (permalink / raw)


Larry Hazel fed this fish to the penguins on Tuesday 05 November 2002 
03:46 pm:

>> 
> If I remember correctly, the Fortran compiler for the SDS/Xerox Sigma
> computers used:
> 
> REPEAT
>     Statements
> WHILE Condition
> 
> or UNTIL Condition
>
        Ooooh... My reference manuals are in storage so I can't check... Of 
course, this was the same compiler that defined a "GLOBAL vars" 
statement... Which effectively translated:

        global x, y, m, n, a

into

        common /x/ x
        common /y/ y
        common /m/ m
        common /n/ n
        common /a/ a

IE, /each/ variable named generated a named common block containing 
only that variable, and the common block name matched the variable name.

--  
 > ============================================================== <
 >   wlfraed@ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
 >      wulfraed@dm.net     |       Bestiaria Support Staff       <
 > ============================================================== <
 >        Bestiaria Home Page: http://www.beastie.dm.net/         <
 >            Home Page: http://www.dm.net/~wulfraed/             <



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-05 13:53         ` Charles H. Sampson
@ 2002-11-06  4:59           ` R. Tim Coslet
  0 siblings, 0 replies; 37+ messages in thread
From: R. Tim Coslet @ 2002-11-06  4:59 UTC (permalink / raw)


Just a bit of trivia, but the counter in an Ada "for" loop is NOT a
variable. It is defined as a *constant* initialized to successive different
values on each iteration of the loop.

If it were a variable the program could change the value with the assignment
statement or by passing it as an out or in out parameter to a procedure.
This is forbidden and will be reported as an error by any validated Ada
compiler.

-- 
        R. Tim Coslet
        r_tim_coslet@pacbell.net

Technology, n. Domesticated natural phenomena.


> From: claveman@grzorgenplatz.net (Charles H. Sampson)
> Organization: NetHere Inc.
> Newsgroups: comp.lang.ada
> Date: Tue, 5 Nov 2002 05:53:55 -0800
> Subject: Re: Local vs global variables in ADA
> 
[...]
> 
> Seriously, here's what I try to do: use the for-loop and while-loop
> only when they express the loop's termination condition.  In other
> words, do not use exit statements within loops of these forms; if a loop
> requires an exit statement, then use an "infinite" loop instead.
> Unfortunately, my will power is often too weak to overcome the
> convenience of the automatically declared counting variable of a
> for-loop.  I'm much better with while loops.
> 
> Charlie




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-06  2:15             ` Dennis Lee Bieber
@ 2002-11-06  7:04               ` Martin Dowie
  2002-11-06 14:40               ` john mann
  1 sibling, 0 replies; 37+ messages in thread
From: Martin Dowie @ 2002-11-06  7:04 UTC (permalink / raw)


"Dennis Lee Bieber" <wlfraed@ix.netcom.com> wrote in message
news:p0u9qa.4p3.ln@beastie.ix.netcom.com...
>         Using just a while loop, as in many languages, the above turns
into:
>
>         (initial) preprocessing which may set flag
>         while not flag
>                 other processing
>                 preprocessing which sets flag
>         wend

AKA the "Read Ahead Principle" so beloved of Jackson Structured Programming
and COBOL-heads.

It wasn't that bad when the preprocessing bit was farmed off to a subpogram
and you wrote your programs using a decent JSP tool.





^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-05 22:37           ` Robert A Duff
  2002-11-05 23:46             ` Larry Hazel
  2002-11-06  2:15             ` Dennis Lee Bieber
@ 2002-11-06  7:18             ` Dale Stanbrough
  2002-11-06 15:40             ` Rod Chapman
  2002-11-06 17:34             ` Stephen Leake
  4 siblings, 0 replies; 37+ messages in thread
From: Dale Stanbrough @ 2002-11-06  7:18 UTC (permalink / raw)


Robert A Duff wrote:

> Like what?  I mean, which languages have different definitions of
> "while" loops, and what are the differences.  I thought "while" loops
> were one of the few cases where there is pretty much agreement on the
> semantics across languages.
> 
> I like while loops, and use them in favor of loop/exit whenever the exit
> condition happens at the top.

Of course the exit has a negated condition compared to the while, so
this may make it easier to read in some situations.

while (not finished) and (not found) loop
   ...
end loop

or 

while not (finished or found) loop

or

loop
   exit when finished or found;
   ...
end loop;


Dale



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-05 19:57             ` Jeffrey Carter
@ 2002-11-06  9:11               ` Jean-Pierre Rosen
  0 siblings, 0 replies; 37+ messages in thread
From: Jean-Pierre Rosen @ 2002-11-06  9:11 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 545 bytes --]

"Jeffrey Carter" <jrcarter@acm.org> a �crit dans le message news:
3DC822DC.1030303@acm.org...
> Jean-Pierre Rosen wrote:
> > In Pascal, a for loop was always done entirely;
>
> Barring a goto. Judicious use of gotos can sometimes make loops in
> Pascal much easier to read and understand.
>
Sure, but I'd bet that those goto's are almost always exit. So you are
supporting my view.... :-)

--
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr





^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-05 23:14             ` Wes Groleau
@ 2002-11-06  9:16               ` Jean-Pierre Rosen
  2002-11-06 13:49                 ` Wes Groleau
  0 siblings, 1 reply; 37+ messages in thread
From: Jean-Pierre Rosen @ 2002-11-06  9:16 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 927 bytes --]


"Wes Groleau" <wesgroleau@despammed.com> a �crit dans le message news:
FhYx9.1648$Bd4.12666@dfw-service2.ext.raytheon.com...
> Jean-Pierre Rosen wrote:
> > In Pascal, a for loop was always done entirely; you have to be aware
that
>
> I'm not sure exactly what that means.  What French word
> were you thinking of for "entirely" ?
>
> Anyway, all the versions of Pascal I know of allow:
>
> FOR     iter  DO     stmt
>
> REPEAT  stmt  UNTIL  cond
>
> WHILE   cond  DO     stmt
>
Sure. By entirely, I meant it is executed  for all values from initial value
to TO value (unless you're playing with the loop control variable, but
that's a different issue).

Of course, I'm talking about "original" Pascal (Wirth), not languages that
have considerable extensions like Turbo.

--
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr





^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-06  2:19               ` Dennis Lee Bieber
@ 2002-11-06 13:45                 ` Dan Nagle
  2002-11-07  0:30                   ` Dennis Lee Bieber
  0 siblings, 1 reply; 37+ messages in thread
From: Dan Nagle @ 2002-11-06 13:45 UTC (permalink / raw)


Hello,

Which, technically, is the only correct way to go...

In Fortran, the common name is global, the variable
names in the common are local names.  Fortran has
no global variable names.

-- 
Cheers!

Dan Nagle
Purple Sage Computing Solutions, Inc.

On Tue, 05 Nov 2002 18:19:04 -0800, Dennis Lee Bieber
<wlfraed@ix.netcom.com> wrote:

<snip requoted>
>>
>        Ooooh... My reference manuals are in storage so I can't check... Of 
>course, this was the same compiler that defined a "GLOBAL vars" 
>statement... Which effectively translated:
>
>        global x, y, m, n, a
>
>into
>
>        common /x/ x
>        common /y/ y
>        common /m/ m
>        common /n/ n
>        common /a/ a
>
>IE, /each/ variable named generated a named common block containing 
>only that variable, and the common block name matched the variable name.

<snip sig>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-06  9:16               ` Jean-Pierre Rosen
@ 2002-11-06 13:49                 ` Wes Groleau
  0 siblings, 0 replies; 37+ messages in thread
From: Wes Groleau @ 2002-11-06 13:49 UTC (permalink / raw)


Jean-Pierre Rosen wrote:
> Sure. By entirely, I meant it is executed  for all values from initial value

I see now.  "Entirely" as in the
the _entire_ loop with no early exit.

Sorry about misunderstanding.
I thought you meant "only" as
as in "no other kind of loop"

"Entirely" is a reasonable
word to use there, although
"completely" might have been
slightly better.




^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-06  2:15             ` Dennis Lee Bieber
  2002-11-06  7:04               ` Martin Dowie
@ 2002-11-06 14:40               ` john mann
  2002-11-07  0:25                 ` Dennis Lee Bieber
  1 sibling, 1 reply; 37+ messages in thread
From: john mann @ 2002-11-06 14:40 UTC (permalink / raw)


Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote in message news:<p0u9qa.4p3.ln@beastie.ix.netcom.com>...
<snip>
>         And /neither/ structure really handles the form where you need a bit 
> of processing before you can do the test...
> 
> 
>         loop
>                 preprocessing which sets flag
>             exit when <cond>
>                 other processing
>         end loop.
> 


Well, you could use a function to get the while test value.
Couldn't you?



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-05 22:37           ` Robert A Duff
                               ` (2 preceding siblings ...)
  2002-11-06  7:18             ` Dale Stanbrough
@ 2002-11-06 15:40             ` Rod Chapman
  2002-11-06 17:34             ` Stephen Leake
  4 siblings, 0 replies; 37+ messages in thread
From: Rod Chapman @ 2002-11-06 15:40 UTC (permalink / raw)


Robert A Duff <bobduff@shell01.TheWorld.com> wrote in message news:
> I seem to recall some issue in SPARK, where they discouraged while
> loops.  Something about wanting to put a loop-invariant before the exit
> condition?  Maybe one of the SPARK folks can comment on that.

Not really - while loops are fine in SPARK.  You can place an assertion
either after the implicit loop exit, thus:

while A loop
   --# assert ... ;
   S;
end loop;

or before it:

while A
--# assert ... ;
loop
   S;
end loop;

or anywhere else in the loop body for that matter.  Note that the first form
does result in an additiona basic path (bypasses the assertion) for the
zero-iterations case.

The rules for placing exit statements in SPARK ensure that the resulting
flow graph is both reducible and can be generated from a semi-structured
graph grammar.  This property makes subsequent analyses (particularly
info flow analysis and verification condition generation) tractable.

 - Rod



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-05 22:37           ` Robert A Duff
                               ` (3 preceding siblings ...)
  2002-11-06 15:40             ` Rod Chapman
@ 2002-11-06 17:34             ` Stephen Leake
  2002-11-10  1:36               ` loop statements, was " David Thompson
  4 siblings, 1 reply; 37+ messages in thread
From: Stephen Leake @ 2002-11-06 17:34 UTC (permalink / raw)


Robert A Duff <bobduff@shell01.TheWorld.com> writes:

> Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov> writes:
> 
> > Never use a "while" loop. Mostly because "exit when" is much clearer,
> > partly because I've used other languages that had slightly different
> > definitions of "while", and I can't keep them straight.
> 
> Like what?  I mean, which languages have different definitions of
> "while" loops, and what are the differences.  I thought "while" loops
> were one of the few cases where there is pretty much agreement on the
> semantics across languages.

I had hoped someone else would actually answer your question, but they
didn't. 

At the moment, I only use Ada and C, so I don't really remember what
the issues are precisely.

What I do remember is being confused about whether the loop body
executes once for a "false" while condition. Especially when the
"while" is at the end.

I believe different languages (I've used Pascal, C, COBOL, Fortran,
lisp, Ada) do this differently. But I could be wrong; it could be that
I could just never remember the (common) rule.

Hmm. Checking my ANSI C manual, I see that if "while" is at the top,
the loop body is not executed if the condition is false. If "while" is
at the bottom, the loop body is executed once if the condition is
false.

Ada only allows "while" at the top, and it has the same rule as C.

Anyway, I see no reason to strain my limited supply of brain cells
trying to remember this, when loop/exit/end loop covers all the cases,
and is perfectly clear.

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-06 14:40               ` john mann
@ 2002-11-07  0:25                 ` Dennis Lee Bieber
  2002-11-07 14:58                   ` Robert A Duff
  2002-11-08  1:43                   ` Jeffrey Carter
  0 siblings, 2 replies; 37+ messages in thread
From: Dennis Lee Bieber @ 2002-11-07  0:25 UTC (permalink / raw)


john mann fed this fish to the penguins on Wednesday 06 November 2002 
06:40 am:

> Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote in message
> news:<p0u9qa.4p3.ln@beastie.ix.netcom.com>... <snip>
>>         And /neither/ structure really handles the form where you
>>         need a bit
>> of processing before you can do the test...
>> 
>> 
>>         loop
>>                 preprocessing which sets flag
>>             exit when <cond>
>>                 other processing
>>         end loop.
>> 
> 
> 
> Well, you could use a function to get the while test value.
> Couldn't you?

        Most of my experience is in FORTRAN, avoiding vendor specific 
extensions, but still... writing whole function WITH SIDE-EFFECTS and 
calling overhead to change

        read(unit,format, iostat=ios) v1, v2, v3
  10    if (ios .ne. EOF_VALUE) then
                other processing
                read(unit,format, iostat=ios) v1, v2, v3
        goto 10
        endif

into
        integer function funcwithsideeffects(a1,a2,a3)
        read(unit,format, iostat=is) a1, a2, a3
        funcwithsideeffects = is
        return

        ...

  10    if (funcwithsideeffects(v1,v2,v3) .ne. EOF_VALUE) then
                other processing
        goto 10
        endif

        
        Would have gotten jeers from code inspections at my former employer. 
Especially as I'd have to document/justify the creation of those 
snippet functions.

        As it is, I only used "goto" in constructs where the destination was 
before the goto (as anyone reading the code should have seen the target 
already, and not have to search). This is why I did not fake the Ada 
loop/exit when/end loop in FORTRAN... If I had, the result would have 
looked like:

   10   continue
                read(unit,format, iostat=ios) v1, v2, v3
                if (ios .eq. EOF_VALUE) goto 20
                other processing
        goto 10
   20   continue


        Granted, Ada's I/O system is such that creating a procedure to 
consolidate the three variable reads into one is feasible -- but again, 
to put the status return into it still requires a function with 
side-effects if one wants to use while ... loop/end loop




--  
 > ============================================================== <
 >   wlfraed@ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
 >      wulfraed@dm.net     |       Bestiaria Support Staff       <
 > ============================================================== <
 >        Bestiaria Home Page: http://www.beastie.dm.net/         <
 >            Home Page: http://www.dm.net/~wulfraed/             <



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-06 13:45                 ` Dan Nagle
@ 2002-11-07  0:30                   ` Dennis Lee Bieber
  0 siblings, 0 replies; 37+ messages in thread
From: Dennis Lee Bieber @ 2002-11-07  0:30 UTC (permalink / raw)


Dan Nagle fed this fish to the penguins on Wednesday 06 November 2002 
05:45 am:

> Hello,
> 
> Which, technically, is the only correct way to go...
> 
> In Fortran, the common name is global, the variable
> names in the common are local names.  Fortran has
> no global variable names.
> 

        Yeah, but when each such common block is allocated a full page (or 
whatever size the linker/OS swapper uses) it gets a bit wasteful of 
memory (the physical memory of my college Sigma-6 was only around 
1MByte, and had to support ~50 active user terminals... 50 "global" 
integers would have taken 25KBytes of memory on page alignments).

-- 
--  
 > ============================================================== <
 >   wlfraed@ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
 >      wulfraed@dm.net     |       Bestiaria Support Staff       <
 > ============================================================== <
 >        Bestiaria Home Page: http://www.beastie.dm.net/         <
 >            Home Page: http://www.dm.net/~wulfraed/             <



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-07  0:25                 ` Dennis Lee Bieber
@ 2002-11-07 14:58                   ` Robert A Duff
  2002-11-07 15:38                     ` Jean-Pierre Rosen
  2002-11-08  1:43                   ` Jeffrey Carter
  1 sibling, 1 reply; 37+ messages in thread
From: Robert A Duff @ 2002-11-07 14:58 UTC (permalink / raw)


Dennis Lee Bieber <wlfraed@ix.netcom.com> writes:

>         As it is, I only used "goto" in constructs where the destination was 
> before the goto (as anyone reading the code should have seen the target 
> already, and not have to search). ...

Hmm.  I have always believed just the opposite: that gotos that jump
forward (and outward) are easier to understand that gotos that jump
backward (and therefore form a loop).

For example, I did a lot of Pascal programming a long time ago, and I
don't think I *ever* wrote a backward-jumping goto.  But I wrote quite a
few loop-exiting gotos (since Pascal doesn't have Ada's "exit" or
"return").  And quite a few "while True do...", since Pascal doesn't
have Ada's plain "loop".

- Bob



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-07 14:58                   ` Robert A Duff
@ 2002-11-07 15:38                     ` Jean-Pierre Rosen
  0 siblings, 0 replies; 37+ messages in thread
From: Jean-Pierre Rosen @ 2002-11-07 15:38 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 880 bytes --]


"Robert A Duff" <bobduff@shell01.TheWorld.com> a �crit dans le message news:
wccznslbf5z.fsf@shell01.TheWorld.com...
> Dennis Lee Bieber <wlfraed@ix.netcom.com> writes:
> For example, I did a lot of Pascal programming a long time ago, and I
> don't think I *ever* wrote a backward-jumping goto.  But I wrote quite a
> few loop-exiting gotos (since Pascal doesn't have Ada's "exit" or
> "return").  And quite a few "while True do...", since Pascal doesn't
> have Ada's plain "loop".
>
And of course, in Pascal you had to use gotos for exceptions... Hence the
proverb (translated from the french book "Ada avec le sourire" (Ada with a
smile):

                     "Never use gotos, and the exception confirms the rule"

:-)

--
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr





^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: Local vs global variables in ADA
  2002-11-07  0:25                 ` Dennis Lee Bieber
  2002-11-07 14:58                   ` Robert A Duff
@ 2002-11-08  1:43                   ` Jeffrey Carter
  1 sibling, 0 replies; 37+ messages in thread
From: Jeffrey Carter @ 2002-11-08  1:43 UTC (permalink / raw)


>Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote in message
>news:<p0u9qa.4p3.ln@beastie.ix.netcom.com>... <snip>
>
>>        And /neither/ structure really handles the form where you
>>        need a bit
>>of processing before you can do the test...
>>
>>
>>        loop
>>                preprocessing which sets flag
>>            exit when <cond>
>>                other processing
>>        end loop.

Isn't this the classic Pascal idiom

while not <cond> do begin
    preprocessing which sets flag

    if not <cond> then begin
       other processing
    end {if};
end {while};

?

-- 
Jeff Carter
"If I could find a sheriff who so offends the citizens of Rock
Ridge that his very appearance would drive them out of town ...
but where would I find such a man? Why am I asking you?"
Blazing Saddles




^ permalink raw reply	[flat|nested] 37+ messages in thread

* loop statements, was Re: Local vs global variables in ADA
  2002-11-06 17:34             ` Stephen Leake
@ 2002-11-10  1:36               ` David Thompson
  0 siblings, 0 replies; 37+ messages in thread
From: David Thompson @ 2002-11-10  1:36 UTC (permalink / raw)


Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov> wrote :
> Robert A Duff <bobduff@shell01.TheWorld.com> writes:
...
> > Like what?  I mean, which languages have different definitions of
> > "while" loops, and what are the differences.  I thought "while" loops
> > were one of the few cases where there is pretty much agreement on the
> > semantics across languages.
...
> At the moment, I only use Ada and C, so I don't really remember what
> the issues are precisely.
>
> What I do remember is being confused about whether the loop body
> executes once for a "false" while condition. Especially when the
> "while" is at the end.
>
As opposed to not executing at all for a false test at the end?
I've never seen *that*, but there are other anomalies, see below.

> I believe different languages (I've used Pascal, C, COBOL, Fortran,
> lisp, Ada) do this differently. But I could be wrong; it could be that
> I could just never remember the (common) rule.
>
> Hmm. Checking my ANSI C manual, I see that if "while" is at the top,
> the loop body is not executed if the condition is false. If "while" is
> at the bottom, the loop body is executed once if the condition is
> false.
>
Or, equivalently but clearer to me, the test is executed at the bottom
of the body.

> Ada only allows "while" at the top, and it has the same rule as C.
>
(Modern) Fortran has DO WHILE which does test at top (before),
which is really just sugar for DO (forever) + IF NOT cond EXIT,
in addition to the traditional arithmetic DO = other langs FOR.
Early Fortran (66) had the infamous one-trip-do-loop:  if you
wrote an empty range e.g. DO I=1,0 it was officially undefined
and some (most?) compilers would execute the body once
before testing at the end, as an optimization -- especially on
S/360 using BXLE.  Modern Fortran requires skipping it.

PL/1 has an amalgamated DO where you can write
an arithmetic range (or at least sequence?) plus a
boolean test at top/before in the same statement!
I vaguely recall algol allowing something similar,
but never used it because it was too confusing.

As already noted, Pascal has WHILE cond DO body
and REPEAT body UNTIL cond with the sense inverted
apparently to make them more obviously different,
as well as FOR.

COBOL (85) is the worst, for my money.  For inline loops
the test always appears at the top of a PERFORM construct
but you can specify either WITH TEST { BEFORE | AFTER }.
This may(?) derive from earlier COBOL having *only* out-of-line
loops -- PERFORM that-code-over-there UNTIL cond , or FOR ~
PERFORM blah VARYING i FROM 1 BY 2 UNTIL i > 9 --
where there is no body to be on the top or bottom of.

Well, actually there's one thing worse -- perl.  You can read
through 20 lines of code thinking it's an imperative statement
and only at the end discover it's a loop.

> Anyway, I see no reason to strain my limited supply of brain cells
> trying to remember this, when loop/exit/end loop covers all the cases,
> and is perfectly clear.
>
Your choice.

--
- David.Thompson 1 now at worldnet.att.net








^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2002-11-10  1:36 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-03 18:17 Local vs global variables in ADA Roger
2002-11-03 19:03 ` Per Sandbergs
2002-11-03 19:31 ` Eric Jacoboni
2002-11-04  1:47 ` Jeffrey Carter
2002-11-04 13:27   ` Wes Groleau
2002-11-04 20:48     ` Jeffrey Carter
2002-11-05  8:43       ` Fraser Wilson
2002-11-05 13:53         ` Charles H. Sampson
2002-11-06  4:59           ` R. Tim Coslet
2002-11-05 17:28         ` Stephen Leake
2002-11-05 17:38           ` Jean-Pierre Rosen
2002-11-05 19:57             ` Jeffrey Carter
2002-11-06  9:11               ` Jean-Pierre Rosen
2002-11-05 20:26             ` Vinzent Hoefler
2002-11-05 23:14             ` Wes Groleau
2002-11-06  9:16               ` Jean-Pierre Rosen
2002-11-06 13:49                 ` Wes Groleau
2002-11-05 22:37           ` Robert A Duff
2002-11-05 23:46             ` Larry Hazel
2002-11-06  2:19               ` Dennis Lee Bieber
2002-11-06 13:45                 ` Dan Nagle
2002-11-07  0:30                   ` Dennis Lee Bieber
2002-11-06  2:15             ` Dennis Lee Bieber
2002-11-06  7:04               ` Martin Dowie
2002-11-06 14:40               ` john mann
2002-11-07  0:25                 ` Dennis Lee Bieber
2002-11-07 14:58                   ` Robert A Duff
2002-11-07 15:38                     ` Jean-Pierre Rosen
2002-11-08  1:43                   ` Jeffrey Carter
2002-11-06  7:18             ` Dale Stanbrough
2002-11-06 15:40             ` Rod Chapman
2002-11-06 17:34             ` Stephen Leake
2002-11-10  1:36               ` loop statements, was " David Thompson
2002-11-05 19:54         ` Jeffrey Carter
2002-11-04 13:47 ` Martin Dowie
  -- strict thread matches above, loose matches on Subject: below --
2002-11-05  6:42 Grein, Christoph
2002-11-05 15:59 ` Martin Dowie

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