As a companion to "Structured Programming with go to Statements" by DONALD E. KNUTH, I see a great need for "Spaghetti Code Without go to Statements". BTDT,GTS.
________________________________________ From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> on behalf of David Crayford <dcrayf...@gmail.com> Sent: Sunday, September 25, 2022 8:38 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Assembler courses According to Linus you’ve been brainwashed by using a garbage language https://secure-web.cisco.com/1AljfkLGGdV0Jty3Ym1w5HatMtcmZ3H0SpTJozVJj2O2mM6H3lJxH92R9iS9tGEwnOKGf5Rr8czIZ8iKjU4KoGgWUmFEOawaqYUlplyg_3woqC2QpQRSTjOR4sIwCmDns8vaTmeMJKq6eofFVp9fmG57yGDYeCz9rdT8VSIt6TZkzleobRrY5rdT86wx1KIhAZEHfJF5zDA_uWnd38OsXN0anZzpfug3AppfFTvJQ-It7zFS7KY2N5rJ0Ra9yOGL2gVhKwo2tHOD85bBqqgJQcn_QXDj0dSlHHe99lnMWR-Pr6AX61h7P4xS0osB1N5s0WBgLIpc9QR6w222GOfpxWsi0wWSJx1b5r2pz_PJ8iPqHhvFQomCjjU4xqMF5kpDbhsUrSB_jVCFTf9ZoDwtEUS_h5UU0t4vTy8GaWhkdryKcd3_qAd17r94Ei2uABI-l/https%3A%2F%2Fkoblents.com%2FChes%2FLinks%2FMonth-Mar-2013%2F20-Using-Goto-in-Linux-Kernel-Code%2F > On 26 Sep 2022, at 1:43 am, Bernd Oppolzer <bernd.oppol...@t-online.de> wrote: > > I try to be not dogmatic about GOTO statements, > in fact, I am coding COBOL in my money (everyday) job, and there are lots of > GO TOs around; > I try to remove them, when I do larger refactoring, but if not, I leave them > untouched. > > But now for another GOTO story. > > When I started my Stanford Pascal compiler adventure in 2011, the first > compiler pass (PASCAL1) > had around 50 GOTO statements in it (in fact: 50 numeric labels which are > targets of GOTOs in Pascal; > in Pascal, BTW, GOTOs are allowed, but they are sort of uncomfortable; > you need a label declaration for them, not only the GOTO statement and the > target label - > because the label is local to a block, the label number may be reused in > different blocks). > The Stanford compiler, as many other Pascal compilers, is self-hosted, > that means, it is written in Stanford Pascal and compiled by itself. > The Stanford Pascal compiler pass 1 had 6.000 lines in 2011 ... with the 50 > labels mentioned above > (well, this was the 1982 McGill version, to be honest). > > One of my first extensions to Stanford Pascal was to add CONTINUE, BREAK and > RETURN statements > to it (semantics like in C). It turned out that almost all GOTOs were used to > implement the missing > statements CONTINUE, BREAK and RETURN using GOTOs. I then started (after some > time) > to remove the GOTOs by replacing them by the new statements, where this was > possible > without problems. > > Today the compiler pass 1 has almost 25.000 lines. It only contains 7 GOTO > statemens (I just checked it). > Because, see above, I am not dogmatic about GOTO, I will leave them, as long > as there is no need > to work on the procedures containing them. > The compiler story (including downloads) is here: > http://secure-web.cisco.com/1SeQcGdriYjXOUOZmJ0TQyNubfV-j2u1wqtZiAsKEVGvUnkEjGQlKIlwL_bHmG-eNMe96E878kRA-dAsBTTUloloysZCZ61Ay5d_7IMHDG1vnhQ2biIAO0BHVDrU887sf2-r95sv7ydGHB2OKEsX8CFPMYsVgfYgli-LImo7OJCItLF3Ez63AslXYlvIDO0U6FlG_STVPESyecE0q-KLvXvZdS6_tXxoI1MV4-6eOquKsggUhiR9uHzhfEkpmpdG73mC2LK4YBbf9I_Cr18yUsr7RBoYiO6J9vjDebBJb8dN43jWuw-E4Sg97svU2mcuLeTuTHgDMYocb4HY7NqR-kt9bU-02vf0UCnmP2ovV9icLKeqp8WD1gfnVj2yq2cNpnsP5qgY-QF37tfgpE-12yeTUm9O_9l4JK_tah8EgA2s7juJf9qDtqxY2RjLLg7BV/http%3A%2F%2Fbernd-oppolzer.de%2Fjob9.htm > > IMO, GOTOs (and the statements mentioned above) must be used with care. > If you don't use them right, nobody will be able to follow the logic in your > programs, > including yourself (after some time). Indentation is key, and meaningful > comments. > > Kind regards > > Bernd > > >> Am 25.09.2022 um 13:51 schrieb David Crayford: >> Another thing that makes me incredibly dubious about some of the opinions in >> these videos is the hackneyed nonsense about "goto considered harmful". The >> original paper was misunderstood in that all goto statements are harmful and >> brainwashed a generation. Some of these videos present a trivial example >> using goto and refactor it using if/ifelse. In programming languages without >> scope based cleanup goto is not harmful. In fact it's leads to clean code as >> the branch direction is always descending to a cleanup block. Happily for >> me, the young guys I work with writing systems level Metal/C code haven't >> been seduced by this dogmatic BS. Good C code uses goto statements as >> opposed to heavily nested or superfluously functionally decomposed routines. >> The IBM Openj9 JVM C code is a case in point >> https://secure-web.cisco.com/1o4CTqAeplBibdg4QNGSL-oBgUrCxA6v8SroEUyENIJO12B9JOE76XYyfw5RkmP-qVQzrbch32X30LaCS721ojaG8MFhZ7APF2YFHBhOC3V6utLVVXTBMsQJOczgx11PJ_zJu2M7YpLSHji0lgcy5KE_Z8THQS4qPiZzeRaJTqLEw4Z9EF4N17cjjuO8P32WST1c3mt4kygcX9ucyjT5qRT8f-mLLrdqCmkUMEv1CeDYwqqWWEmy3K3CpTDmHqronR9zkcYEvKPNYTRexTj9NbvF3kkbF35Xs_UAV3q60lyUJFExK_cBuAfQ4NY3bZUAuB8R8mKCnWTdcFW3wOh7TjvGyL5pLJnlMD5jmNCVH-fBDJL7uO7d7mmrY4NdIF1o0t1v2gTpLRI9wnwDzLQPJkrwF8DdCWtuvnj24lPOhaPZ2uk83eWVK2whAI0DVHeE2/https%3A%2F%2Fgithub.com%2Feclipse-openj9%2Fopenj9%2Fblob%2Fmaster%2Fruntime%2Fvm%2Fclasssupport.c. >> I challenge anybody to write better code without goto statements. >> >> > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN