Re: Try/catch for modules?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 18 Oct 2019 12:43:58 -0300, Martin Galvan said:

> goto statements are harmful.

For starters, note that the original paper was written in 1968. Yes, it's over
a half century old now.

Have you actually *read* the paper?

https://homepages.cwi.nl/~storm/teaching/reader/Dijkstra68.pdf

You probably want to keep in mind that in 1968, most languages in widespread
use (in other words, Fortran and COBOL, effectively) did *not* have any concept
*at all* of "structured programming" supported by language syntax. 

Fortran had exactly one explicit iterative syntax, the DO loop, which was a
subset of the C for loop.

It also had the infamous and dangerous 'arithmetic if' statement, which was of
the format 'if (condition) A,B,C' - which was a *three* way goto to labels A B
or C depending if 'condition' was negative, zero, or positive.  Yes, this meant
that the following statement *had* to have a goto target label on it in order
to be reachable code.

There was also 'GOTO A,B,C,...,integer variable', which would branch to
label A if the variable was 1, B if it was 2, etc...

And  the creeping horror known as 'assigned goto'.

      ASSIGN 10 TO N 
       ... 
       GO TO N ( 10, 20, 30, 40 ) 
       ... 
10     CONTINUE 
       ... 
40     STOP

Now imagine a large subroutine that takes most of a box of punched cards, and
5 or 6 different variables containing assigned targets, and the GOTO can branch
to *anywhere* in the current compilation unit.

(If that isn't bad enough, the IBM Fortran IV G compiler included an extension
called 'debug units', which *really* *did* have the semantics of the joke statement
'COME FROM'.)

Fortran wouldn't get a 'while' for another 15 years or so.  And the COBOL 'PERFORM'
verb is best not approached without first  fortifying yourself with strong drink.

That was the reality that Dijkstra was writing about at the time.

Also consider where Dijkstra's head was when he wrote the paper, which also
includes this statement:

"Let us now consider repetition clauses (like, while B repeat A or repeat A
until B). Logically speaking, such clauses are now superfluous, bcause we can
express repetition with the aid of recursive procedures."

Yeah.  Exactly.

Let's return to 2019.

Feel free to look at function hi_command() in drivers/media/dvb-frontends/drx39xyj/drxj.c
and re-write it in standard nested if/then/elseif/then/elsif/then... form.
Watch out for the fact that the case statement uses fallthroughs.  Let us know
the maximum number of leading tabs your version uses.

Another good challenge is to unsnarl the gotos in the TLV_PUT macros in
fs/btrfs/send.c into a form that doesn't use goto.

There's plenty of good reason to use goto's when implementing a
finite state machine.

At some point, purity needs to take a back seat to pragmatism.

Attachment: pgpzEiUBdDNHL.pgp
Description: PGP signature

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

  Powered by Linux