Hi Hamish,

> I've heard bad things about goto :)

Forget all you've heard.  :-)

The problems with goto date back to languages that offered a one-line
if-statement that could goto.  No other control-flow than goto existed;
no while-loop, for-loop, etc.  This included very popular languages that
were the mainstream, e.g. FORTRAN 77, that I and others here used.
Unfettered use of conditional goto then created a tangle of flow that
could be difficult to follow, especially as labels were just numbers and
didn't need to be in numerical order.  Oh, and labels were also used for
I/O formatting.  :-)  Thus it was easy for code to `bit rot' into a
tangle over time.

Structured used of goto, including conditional goto, was fine.
It's just your normal control-flow structures written a different way.
In the 70s, a movement gained ground, Structured Programming, to promote
this style and goto was tamed.

But goto still exist, and very useful it is too, allowing flow not
possible without it without overhead.  Donald Knuth's 1974 paper,
_Structured programming with go to statements_, is a good read if you
want to see why.
https://lxr.missinglinkelectronics.com/linux/fs/file.c#L85 is an example
from the Linux kernel of its continuing use.

And of course, behind the scenes, your CPU is doing goto and conditional
goto all the time; it has nothing higher level.  It also has interrupts,
that are a goto that can happen without a goto instruction.  :-)

-- 
Cheers, Ralph.

-- 
  Next meeting: BEC, Bournemouth, Tuesday, 2019-06-04 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk/
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk

Reply via email to