GOTO is alive and well. Dijkstra, eat my pants

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
If you "abandon memory test early by pressing escape" during PC boot
up the reply is invariably:-

2^X  OK

Some companies have no pride.

Cheers
Robin

Re: GOTO is alive and well. Dijkstra, eat my pants

Quoted text here. Click to load it

As if BIOS tests give accurate results anyway.  I've seen memory that
always test OK by the BIOS even when doing the slow test, but fails when
HIMEM.SYS /TESTMEM:ON is used.  Not to mention the memory that passes
the HIMEM test and fails on MEMTEST86 or Linux kernel compiles.

At any rate you're still incorrect because some PC BIOS's will say XXXXX
skipped or some other variation.


Re: GOTO is alive and well. Dijkstra, eat my pants
On 8 Jun 2004 00:35:12 -0700, snipped-for-privacy@tesco.net
Quoted text here. Click to load it
What has Dijkstra to do with this?

Pieter


Re: GOTO is alive and well. Dijkstra, eat my pants
Quoted text here. Click to load it

He hasn't, that's the point. His 1975 "How to we tell truths that
might hurt?" (re: "IBMerese" and later on "IBM equipment") coupled
with his warnings on the use of GOTO are cheerfully alive and well in
the above example.

Cheers
Robin

Re: GOTO is alive and well. Dijkstra, eat my pants

Quoted text here. Click to load it
Unlike Dijkstra..





Re: GOTO is alive and well. Dijkstra, eat my pants
Quoted text here. Click to load it

 :(

...on the otherhand he is more alive than ever by his legacy and
attitude to "authority", reminiscent of Feynmann, another generous
soul.


Cheers
Robin

Re: GOTO is alive and well. Dijkstra, eat my pants
Quoted text here. Click to load it

Richard Feynman is another hero of mine... Good chap - but no saint, which
somehow made him all the more endearing ;).

Steve
http://www.sfdesign.co.uk
http://www.fivetrees.com



Re: GOTO is alive and well. Dijkstra, eat my pants
Quoted text here. Click to load it

Yes, naughty is loveable, but saintliness is... don't ya just hate it!
On the otherhand, a saint usually a pain in the arse (to "authority").

Cheers
Robin

Re: GOTO is alive and well. Dijkstra, eat my pants
Quoted text here. Click to load it

So what makes you think they've used a GOTO? Have you disassembled the BIOS?

Steve
http://www.sfdesign.co.uk
http://www.fivetrees.com



Re: GOTO is alive and well. Dijkstra, eat my pants
snipped-for-privacy@NOSPAMTAfivetrees.com says...
Quoted text here. Click to load it

The 'goto' instruction is actually alive and well in a lot of compiled
code.  I've disassembled a lot of FOR loops that start with a 'goto'
(or branch or jmp)  over the internals of the loop and to the
terminating condition test at the end of the code.  I suppose the
same sequence is used in 'while(!KeyPressed() ).

Quoted text here. Click to load it
Mark Borgerson



Re: GOTO is alive and well. Dijkstra, eat my pants
Quoted text here. Click to load it

Maybe you all have missed professor Dijkstra's point: The main idea
in his paper was that the code *must* be constructed from simple
blocks with one entry and one exit only. The components of a block
can then be similar blocks. The common high-level language constructs
belong to this class: if-then, if-then-else, do-while, while, switch and
procedure call.v

The prohibited use of jumps (branches, goto's) is to enter the insides
of another block from the side (not ia the only allowed main entry), as
this usage leads to tangled spaghetti code soon resembling the Gordion's
knot.

Tauno Voipio
tauno voipio @ iki fi


Re: GOTO is alive and well. Dijkstra, eat my pants
Quoted text here. Click to load it

In assembler, one implements closed constructs with jumps. That's all you've
got ;).

Quoted text here. Click to load it

Exactly so.

Steve
http://www.sfdesign.co.uk
http://www.fivetrees.com



Re: GOTO is alive and well. Dijkstra, eat my pants
Quoted text here. Click to load it


Yes, but look at the second reference in Djikstra's letter: Bohm and
Jacopini.


John


Re: GOTO is alive and well. Dijkstra, eat my pants

Quoted text here. Click to load it

That doesn't mean that Dijkstra _didn't_ make the statement
that "goto's" were a bad thing and should be avoided.  It
appears that Böhm et al showed that gotos weren't required for
Turing completeness outside of the the rules given [I haven't
read their paper].

Dijkstra's point is that that not only can they be avoided,
they _should_ be avoided because they result in unreadable and
unmaintainable code. Dijkstra doesn't claim to have invented
that opinion (he explicitly states others have made that point
before). Dijkstra was, however, the one who summed it up and
made it famous.

So the answer to the question about whether the poster was
confusing Dijkstra with Böhm et al, is "no". The editorial
cited was written by Dijkstra and is that which was being
aluded to.  I simply can't believe that Dijkstra's name doesn't
pop into the head of anybody with a CS background when the
topic of avoiding goto's is raised.

--
Grant Edwards                   grante             Yow!  Somewhere in Tenafly,
                                  at               New Jersey, a chiropractor
We've slightly trimmed the long signature. Click to see the full one.
Re: GOTO is alive and well. Dijkstra, eat my pants

Quoted text here. Click to load it

Dijkstra et al probably didn't write much code in the real world, where a major
part of the work is
error handling - an absolute nightmare to do in any sort of 'structured' way. On
Error Goto is
efficient and clear.

Re: GOTO is alive and well. Dijkstra, eat my pants
On Wed, 09 Jun 2004 19:03:30 +0100, Mike Harrison

Quoted text here. Click to load it
part of the work is
Quoted text here. Click to load it
On Error Goto is
Quoted text here. Click to load it

Of course they are efficient.  But the implications of such a go-to
are far from clear.  Sometimes error handling requires de-allocating
resources to make a decent recovery from the error.  If you react to
an error with a go-to, then you have to manually check each and every
place where such a go-to is used to see if it is in such a context
that it requires some clean-up.  Later on, if you add something to the
code that allocates a resource, you might miss that go-to in checking
where clean-up is required.  Although it seems messy (not a
"nightmare") A structured recovery does provide a lot of automatic
clean-up, resulting is less buggy code.


-Robert Scott
 Ypsilanti, Michigan
(Reply through this forum, not by direct e-mail to me, as automatic reply
address is fake.)

Re: GOTO is alive and well. Dijkstra, eat my pants
On Wed, 09 Jun 2004 19:53:11 GMT, no-one@dont-mail-me.com (Robert

Quoted text here. Click to load it
major part of the work is
Quoted text here. Click to load it
On Error Goto is
Quoted text here. Click to load it

This is not really a problem in languages, in which you can have
labels with descriptive names (but a lot messier, if only numeric
labels are available, such as old Fortran and Pascal).

Just put the error handlers with a descriptive label _after_ the
normal return path of the function (as with exception handlers), do
the clean-up relevant to that error and return a specific error code.
In some situations it also can be useful to let the error handlers
fall through to the next error handler. Thus, placing the error
handler that needs to do most error cleanup first and the last error
handler, which does not need any cleanup last just before the return
statement, sometimes simplifies the program.

Of course, in the beginning of the functions, the validity of all
parameters should be checked and return immediately with an error code
if something is wrong.

Only after this, should any resources allocated. In this way, in the
actual function logic you have to deal with "unpredictable" errors,
such as I/O errors and jump to the appropriate error handler.

By doing this, the function actual logic can be kept simple and
readable,  the indentation can be kept well below 80 columns, which
also makes it easier to use longer, descriptive names, without having
to divide each statement to multiple lines or scroll the display.

In the days Dijkstra wrote the article, a large number of programs
were really a mess, since simply the main programming languages in
those days (Fortran and Cobol) did not offer any real block control
structures. The article encouraged  compiler writers to include the
ideas into the main stream programming languages, which clarified the
program logic of new programs.

Unfortunately, the paper also created a hysteria against gotos and in
some languages even created all kinds of syntactic sugar, to hide that
"dirty" goto word, e.g. when implementing a similar error handling
mechanism as described above.

Paul
        

Re: GOTO is alive and well. Dijkstra, eat my pants
Quoted text here. Click to load it
major part of the work is
Quoted text here. Click to load it
way. On Error Goto is
Quoted text here. Click to load it

I hear this argument a lot, and it's bollocks, to be blunt. I do do a lot of
real-world programming. I'm very hot on error handling (someone once said
that the quality of a piece of code could be inferred by its error handling,
and I'd buy that). I haven't used a goto (in C etc) since the late 70s when
I learned how to avoid them. Nasty, nasty things ;).

As another poster has said, there are better ways which don't break
structure. State machines spring to mind.

BTW, Dijkstra was no simple theorist. He virtually wrote the book on
real-world programming.

Steve
http://www.sfdesign.co.uk
http://www.fivetrees.com



Re: GOTO is alive and well. Dijkstra, eat my pants
Quoted text here. Click to load it
a
of
handling,
when

Sometimes goto's can be handy, to jump out of a few nested loops
inside a function, where a break doesn't handle the situation. As
long as it fits within one page... but I honestly can't remember
the last time I used it. Once a year perhaps. Similar to 'continue',
that's another one that I don't use often. Less than goto ;)

[snip]

--
Thanks, Frank.
(remove 'x' and 'invalid' when replying by email)



Re: GOTO is alive and well. Dijkstra, eat my pants

Quoted text here. Click to load it

Hi all,

Sorry for asking stupid question:
Will C compilers generate same code for "break" and "goto" ?

e.g.
// using break
for (i=0;i<10;i++) {
   if (cond) break;
   ...
   }
...

// using goto
for (i=0;i<10;i++) {
   if (cond) goto loopexit;
   ...
   }
loopexit:
...

Joe

Site Timeline