arnold(a)skeeve.com wrote in
<202012011639.0B1GdjcD031722(a)freefriends.org>:
|> On Tue, Dec 1, 2020 at 8:39 AM <arnold(a)skeeve.com> wrote:
|>> It was recognized that goto was not necessary if one had proper control
|>> structures in a language (if/else, while), and that code with no (or
|>> minimal) gotos was easier to read and understand.
|
|Warner Losh <imp(a)bsdimp.com> wrote:
|> This is true for simple flow control. However, when you had to break \
|> out of
|> multiple levels, or continue not the inner loop, but the middle loop, the
|> use of extra booleans sure made the code less understandable than \
|> a 'goto'
|> a label that stood in for that purpose... This was something that wasn't
|> well understood by language designers, and even today C and C++ neither
|> have good flow control beyond the basics. Even though both break and
|> continue could take an optional count without breaking old code....
|
|Quite true. Modern Bourne shells let you supply a number to break and
|continue to specify how many loops to break. Ada, or maybe it was one of
|the Modula-X languages, let you put a label on a loop so that you could
|say `continue outer' or `break outer' and not need the booleans.
Bah, and perl could and obsoleted it, or at least jumping into
blocks (not crossing initializers)! You now write code like
my $ogoditisanewperl = 0;
if(defined($nl = $self->begin_line)){
$self->begin_line(undef);
$self->seen_endl(1);
$ogoditisanewperl = 1 #goto jumpin;
}
while($ogoditisanewperl || ($nl = readline $self->infh)){
if(!$ogoditisanewperl){
++${$self->__lineno};
$self->seen_endl($nl =~ s/(.*?)\s+$/$1/)
}
$ogoditisanewperl = 0; #jumpin:
or even have to work with closures or whatever, or the worst, code
duplication.
|This is something that newer languages (C#, Java, Go, ...) could have \
|picked
|up but didn't, which I think is too bad.
Never without my goto:, and if it is only to break to error
handling and/or staged destruction of local variables after
initialization failures. Traumatic school impression, finding
yourself locked in some PASCAL if condition, and no way to go to.
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)