comp.lang.ada
 help / color / mirror / Atom feed
From: "chris.danx" <chris.danx@ntlworld.com>
Subject: Re: an infinate loop
Date: Fri, 13 Jul 2001 21:40:17 +0100
Date: 2001-07-13T21:40:17+01:00	[thread overview]
Message-ID: <C%I37.36862$B56.7376962@news2-win.server.ntlworld.com> (raw)
In-Reply-To: 3B4F2962.25BB60FF@boeing.com


> > For another, most of your "exit" statements are all at the tops of the
loops. In
> > those cases you should probably reverse the test logic and use "while" loops
> > instead.
>
> This is bad advice. The form that uses positive logic is best.

?

What is positive/negative logic?

Do you mean

while y is true loop is negative logic,

but loop ... exit when x is true is positive logic?

I just don't see it?


> exit when End_Of_File;
>
> uses positive logic, and is better than
>
> while not End_Of_File loop
>
> which uses negative logic. All of the exits in this program use positive
> logic. In general, exit tends to use positive logic and while tends to
> use negative logic.

I don't get it.  Can you explain this to me?  All my tutors and lecturers say
while is better than loop for most occasions.  All the books i've read say the
same.

Is this just a matter of style?



[ I did wonder about Beau's use of loop exit and he/she (I don't know if that's
a masculine name or a feminine name) said the tutors recommend loop over while,
which I thought curious since I've always learned it the other way.]


> At the "Ada Launch" (1980 Dec 10), Ichbiah, Barnes, and Firth introduced
> the recently renamed Ada language (MIL-STD 1815, formerly Green, now
> known as Ada 80) to the world. They said "while" was in the language
> primarily to support translation from languages such as Pascal, and
> advised using the "loop ... exit when" format in new code.

Oh, so Ada might have ended up wirth no while had there been no concern for
translation between Ada and other languages?


TBH: I prefer the info at the top of structures so i don't have go far to find
it.  Getting the conditions right is easier (for me) if this is the case.
procedures, functions, while, for, discriminant records/tasks, etc all have the
conditions and info at the top, which I find better for me.  It's just a
preference, and I have no difficulty with other ppl using different schemes.
I'd just like to know what all the fuss is about i guess.

Chris




  parent reply	other threads:[~2001-07-13 20:40 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-12 21:43 an infinate loop Beau
2001-07-13  3:21 ` DuckE
2001-07-13 13:57 ` Ted Dennison
2001-07-13 17:01   ` Jeffrey Carter
2001-07-13 18:11     ` Ted Dennison
2001-07-13 22:26       ` Jeffrey Carter
2001-07-16 15:14         ` Marin David Condic
2001-07-17 17:02           ` Matthias Kretschmer
2001-07-17 17:56             ` Marin David Condic
2001-07-17 19:25               ` Ted Dennison
2001-07-19 11:38                 ` Matthias Kretschmer
2001-07-19 14:28                   ` Ted Dennison
2001-07-17 17:13           ` Warren W. Gay VE3WWG
2001-07-14 23:41       ` Darren New
2001-07-16 13:24         ` Ted Dennison
2001-07-16 15:19           ` Marin David Condic
2001-07-13 20:40     ` chris.danx [this message]
2001-07-13 22:29       ` Jeffrey Carter
2001-07-14 14:00         ` Robert Dewar
2001-07-14 16:17           ` Negative Logic (was: Re: an infinate loop) Jeffrey Carter
2001-07-17  4:06             ` Robert Dewar
2001-07-17  4:23             ` Robert Dewar
2001-07-16  9:26           ` an infinate loop Philip Anderson
2001-07-19  9:32             ` an infinite [was: infinate] loop AG
2001-07-15 21:18   ` an infinate loop Matthias Kretschmer
2001-07-16 21:59   ` Stephen Leake
2001-07-13 16:48 ` C. Bauman
replies disabled

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