comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Building an encapsulated library that uses GNAT sockets under Windows
Date: Wed, 27 Apr 2016 17:16:06 -0500
Date: 2016-04-27T17:16:06-05:00	[thread overview]
Message-ID: <nfrdn6$iho$1@loke.gir.dk> (raw)
In-Reply-To: cf442cc4-8123-4815-8b49-ce1411ff4ed0@googlegroups.com

<ahlan.marriott@gmail.com> wrote in message 
news:cf442cc4-8123-4815-8b49-ce1411ff4ed0@googlegroups.com...
...
> In the late seventies we were taught that gotos were evil and never
> to be used yet here they are, three and a half decades later, still using
> them - what a disgrace - have people no shame? ;-)

I hope the smiley face applies to the entire rant about Gotos.

When we discussed whether Ada should have a loop continue statement, the 
conclusion was that goto is good enough for such cases. They aren't common 
enough to justify adding a new kind of statement, especially one that can 
get lost (some people dislike deeply nested return statements, and 
"continue" would be worse). We even changed the syntax slightly to make it 
legal for a label to be the last thing in a sequence of statements.

That is:

     loop
          {some code}
          if something then
              goto Continue;
          end if;
          {more code}
     <<Continue>> -- Ada 95 requires "null;" here, Ada 2012 does not.
     end loop;

See AI05-0179-1 for details.

To completely eliminate the goto, one has to use a Boolean variable instead, 
or duplicate parts of the loop; both of those obscure what is going on more 
than the goto.

Moral: all gotos aren't bad. Coding standards that reject them out of hand 
are just like coding standards that reject exception handling or 
finalization out of hand -- deeply flawed.

                                      Randy.



  parent reply	other threads:[~2016-04-27 22:16 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-21 12:59 Building an encapsulated library that uses GNAT sockets under Windows Dmitry A. Kazakov
2016-04-22  7:58 ` ahlan.marriott
2016-04-22  8:23   ` Dmitry A. Kazakov
2016-04-23  9:20     ` Ahlan
2016-04-23  9:48       ` Dmitry A. Kazakov
2016-04-23 14:45         ` ahlan.marriott
2016-04-23 19:56           ` Dmitry A. Kazakov
2016-04-23 21:16             ` Simon Wright
2016-04-24  8:13               ` ahlan
2016-04-24  8:31                 ` Simon Wright
2016-04-26 19:43                   ` ahlan.marriott
2016-04-26 20:24                     ` Simon Wright
2016-04-26 22:32                     ` Jeffrey R. Carter
2016-04-27 22:16                     ` Randy Brukardt [this message]
2016-04-27 23:43                       ` Jeffrey R. Carter
2016-04-28  5:18                         ` J-P. Rosen
2016-04-28  5:59                           ` Jeffrey R. Carter
2016-05-09 22:32                             ` David Thompson
2016-04-28 20:23                         ` Randy Brukardt
2016-04-28 21:47                           ` Jeffrey R. Carter
2016-04-28  5:13                       ` J-P. Rosen
2016-04-26 20:20               ` Dmitry A. Kazakov
2016-04-26 21:23                 ` Simon Wright
2016-04-27  6:53                   ` Simon Wright
2016-04-27  7:25                     ` ahlan
2016-04-27  8:27                   ` Dmitry A. Kazakov
2016-04-27  9:59                     ` Simon Wright
replies disabled

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