Computer Old Farts Forum
 help / color / mirror / Atom feed
* [COFF] continue N. (Was: I can't drive 55...)
       [not found]       ` <20230310165552.czZmL%steffen@sdaoden.eu>
@ 2023-03-11 11:25         ` Ralph Corderoy
  2023-03-11 15:42           ` [COFF] " Paul Winalski
  2023-03-11 17:51           ` Steffen Nurpmeso
  0 siblings, 2 replies; 3+ messages in thread
From: Ralph Corderoy @ 2023-03-11 11:25 UTC (permalink / raw)
  To: coff

Hi Steffen,

COFF'd.

> Very often i find myself needing a restart necessity, so "continue
> N" would that be.  Then again when "N" is a number instead of
> a label this is a (let alone maintainance) mess but for shortest
> code paths.

Do you mean ‘continue’ which re-tests the condition or more like Perl's
‘redo’ which re-starts the loop's body?

   ‘The "redo" command restarts the loop block without evaluating the
    conditional again.  The "continue" block, if any, is not executed.’
        — perldoc -f redo

So like a ‘goto redo’ in

        while (...) {
    redo:
            ...
            if (...)
                goto redo
            ...
        }

-- 
Cheers, Ralph.

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

* [COFF] Re: continue N. (Was: I can't drive 55...)
  2023-03-11 11:25         ` [COFF] continue N. (Was: I can't drive 55...) Ralph Corderoy
@ 2023-03-11 15:42           ` Paul Winalski
  2023-03-11 17:51           ` Steffen Nurpmeso
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Winalski @ 2023-03-11 15:42 UTC (permalink / raw)
  To: coff

Regarding the general subject of using GOTOs:

The first computer on which I did hands-on programming was an IBM
S/360 model 25.  It had 32K of memory available for user
programs--that's both instructions and data.  It executed code at
about a 30 KIPS (yes--KILO instructions/second) rate.  When you're
programming on a machine that is that slow and with that limited an
address space, every instruction counts.  You couldn't afford either
the space or the time to execute conditional tests just to avoid a
GOTO.

Programming using GOTOs doesn't necessarily mean you're writing rat's
nest or spaghetti code.  Yes, you can make a mess using GOTOs, and
perhaps messy code is easier when GOTOs are allowed, but structured
programming just for its own sake can lead to convoluted and messy
program structure as well.  What was rat's nest control flow with
GOTOs can turn into rat's nest data flow of state variables.

It's also worth noting that one of the main functions of a modern
optimizing compiler is to take your nice, structured program and put
all those rat's nest GOTOs (unconditional branch instructions) back so
the thing will execute more quickly.

-Paul W.

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

* [COFF] Re: continue N. (Was: I can't drive 55...)
  2023-03-11 11:25         ` [COFF] continue N. (Was: I can't drive 55...) Ralph Corderoy
  2023-03-11 15:42           ` [COFF] " Paul Winalski
@ 2023-03-11 17:51           ` Steffen Nurpmeso
  1 sibling, 0 replies; 3+ messages in thread
From: Steffen Nurpmeso @ 2023-03-11 17:51 UTC (permalink / raw)
  To: Ralph Corderoy; +Cc: coff

Ralph Corderoy wrote in
 <20230311112508.7306220145@orac.inputplus.co.uk>:
 |Hi Steffen,
 |
 |COFF'd.
 |
 |> Very often i find myself needing a restart necessity, so "continue
 |> N" would that be.  Then again when "N" is a number instead of
 |> a label this is a (let alone maintainance) mess but for shortest
 |> code paths.
 |
 |Do you mean ‘continue’ which re-tests the condition or more like Perl's
 |‘redo’ which re-starts the loop's body?

No Ralph, i unspecifically meant multiple nested loops where some
inner has to restart/continue the outer (at some point).
So a bit like that of "man perlsyn", but with deeper nesting

       If you need both "next" and "last", you have to do both and also use a
       loop label:

           LOOP: {
               do {{
                   next if $x == $y;
                   last LOOP if $x == $y**2;
                   # do something here
               }} until $x++ > $z;
           }

--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)

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

end of thread, other threads:[~2023-03-11 17:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20230309230130.q4I-f%steffen@sdaoden.eu>
     [not found] ` <RHglcvrCs_xHL1NWcH8pkN1l-IQKszfwYFc8sXRTQRRjGa-7kVJWj-OMzOmWkR89xFwEIiWfoLoAAEHkKF8etYwLR3aGRj9VuwO_MhYbz3s=@protonmail.com>
     [not found]   ` <CANCZdfpj_uBkH=hih2Kv+YwTQ-eHOzqgDUJ_+P8a4chOHu=cLQ@mail.gmail.com>
     [not found]     ` <alpine.BSF.2.21.9999.2303101657460.4881@aneurin.horsfall.org>
     [not found]       ` <20230310165552.czZmL%steffen@sdaoden.eu>
2023-03-11 11:25         ` [COFF] continue N. (Was: I can't drive 55...) Ralph Corderoy
2023-03-11 15:42           ` [COFF] " Paul Winalski
2023-03-11 17:51           ` Steffen Nurpmeso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).