Hi,

At least since 50 years it is understood that structured programming does'nt 
mean goto less.

D. Knuth's response to Dijkstra explains other things:

    All the examples are about 15 lines. Knuth shows different versions of the 
same algo.

    As long as you have 15 lines, you can find understandable code without "respecting" the purist "structured programming" dogma.

Interesting btw is the problem of "off by one" counters etc. control flow is 
not all.

It is shown that break, leave, repeat etc. are not sufficient (especially without 
"labels" )

do a nesting of for and switch/case and somewhere down a break... oops.


Now:

I (vaguely) remember an article talking about 'totally unstructured programs"

to explain:  an IF statement can be seen as a function of three (function) variables, the test and the two branches, this can also represented as the standard flowchart etc

While is similar with two parameters, the test, and the body.

Now take some funny (small) spaghetti flowchart with let's say three test and four actions connected in some way that cannot be expressed *easily* with the purist if/while etc.

what such operators can be useful, An unfamous is the python "else" on a for. It seems to that python tries to find simple to understand feature litle with conttextmanagers, For example not requiring to say close of a file that is opened in a with,

There is IMO another small example that consist of replacing    " a ; if (b) then c else d" by "if (a; b) then c alse d" to get rid of some if cascades "... else a; if b " to "elseif (a,b) then"  or

instead of      a; while b do c; a endwile to while (a, b) do c endwhile.

there are channels in "go". Looking at it, well, may give you cancer :-)



The linux kernel example:  it is language parsing with backtracking. the 
example is a shotgun parser.

You may use "predicates' of C..A.R. Koster's (Kees) CDL. A predicate is a function returning true or false, when false, there are no side effects.

The point iagain is quantum entanglement at large distance? . If the "repairing" is far down in the code, you cannot see it, and maybe you forget to code it

(like in a big blok of code that starts with open and two pages later you need or have forgotten the close.

Why was PASCAL popular in the early 80s on IBM machines. C was very bad, Donald Knuth used it, the IBM compiler was good on MVS and VM, not dynamic libraries. And one could write ANSI83 code that was usable on other systems (did that for some CDC). Remember BITNET NJE routing tables ;-)

here a little unstructured program. Assume whatever necesarry length of p let's 
say length 10000.

for a brute force, you might want to replace  ++ by some incr function that adjusts p, or tells "probably no halt after 10000 or so.

For which arrays p does the program halts?

l0: y1 = 1;
    y2 = 2;
    y3 = 3;;

l1: y3++;
    if (p[y3]) goto l2;
    goto halt;

l2: y3++;
    if (p[y3]) goto l4;

l3: y2++;
    if (!p[y2]) goto l2 ;

    y1++;
    if (!p[y1]) goto l1 ;
    goto halt;

l4: y1++;
    if (p[y1]) goto l3;
    goto halt;

halt:

I did this in assembler, so we can continue on the original question now?

the problem is about 50 years old. Whoever is aware of it, please don't 
immediately reveal the source.

best

Peter













----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to