Re: EOF and GOTO and 0th array element
- Posted by Kat <gertie at PELL.NET> Aug 24, 2002
- 501 views
On 24 Aug 2002, at 11:41, Juergen Luethje wrote: > > jbrown105 <jbrown105 at speedymail.org> wrote: > > > On 0, Juergen Luethje <jluethje at gmx.de> wrote: > >> > >> Hello Derek, > >> > >> Derek <ddparnell at bigpond.com> wrote: > > [Derek's proposal for enhancement of the exit statement] > > > Goto could be used for the same purpose. > > Technically speaking, this is correct of course. But that's not an > argument for the use of GOTO. Not anything that could be done, also > should be done. GOTO isn't necessary at all. But yet the assy code under Eu is full of them. > <snip> > > >> the explicit GOTO statement, that is provided by BASIC and other > >> languages, and that obviously some people would like to see in > >> Euphoria. > > > Such as I. With goto, exit/continue/exit(n)/next(n) would not be > > needed. > > Of course, with goto, for..end for/while..end while/if..end > > if/select..end select or even procedure..end procedure/function..end > > function wouldn't be needed either. > > Right, but there has been good reasons why Rob nevertheless decided to > implement while..end while etc. in Euphoria. > Arguing this way, I also could say Euphoria would not be needed at all, > because programs can be written in assembler. > > The bottom line is, that GOTO is a low level statement, for which there > is no place in a high level language like Euphoria. High level languages > should encourage structured programming and structured thinking. Define "structured". You mean it looks nice when printed out in your text editor, right? Or in blocks of code *you* understand, regardless of how anyone else processes the code in their head? Or how you see the flow of the thread, with lots of boolean tests to interrupt getting from point A to point B? > GOTO doesn't do that. GOTO isn't necessary in a high level language such > as Euphoria, but GOTO has the potential to produce "logical spaghetti", > which will lead to less readable and less maintainable code. And hammers can be used as weapons, and so we should outlaw hammers. Potato chips can choke presidents of the usa named Bush, so we should outlaw them too,,, on 2nd thought..err,, nevermind. > If I want to do low level coding, I'll do it in assembler -- it is much > fun for me, I don't know a better low level language, and I can do as > much conditional and unconditional jumps as I like. But I like > Euphoria, because it is a high level language. And I would like it to > remain a high level language. > > > My proposal: implement goto and goto-alternatives, and then let > > the community decided which style is best by seeing which one is used > > more often. > > "best" and "most often" aren't synonyms, unfortunately things are more > complicated ... I agree. Look at all the fuss over using one simple word like goto. It can be the least used keyword, but still the best in certain situations. > There are fairly enough other languages that provide GOTO. Why not keep > at least one high level language clean? > > >>>> <quote> > >>>> Many authors have suggested language features [...] > >>>> which are expressed in terms of *exit*, *jump-out*, > >>>> *break*, or *leave* statements. Kosaraju [57] has > >>>> proved that such statements are sufficient to > >>>> express all programs without *go to*'s and without > >>>> any extra computation, but only if an exit from > >>>> arbitrarily many levels of control is permitted. > >>>> <unquote> > >>>> [Knuth, Donald E.: Structured Programming with go to Statements. > >>>> Computing Surveys, Vol. 6, No. 4, December 1974, pp. 261-301] > > <snip> > > > If used in a limited fashion, goto works fine with easily-readable > > code. > > This is often said in this context. The decisive word is *if* ... > After (not only) my experience, this is just a theoretical consideration. > In practice, GOTO is *not* used in a limited fashion in (far too) many > programs. I say this after having read *megabytes* of BASIC source code. And lots of people use pliers as an 8oz hammer, when they don't have an 8oz hammer. Most people use a worn screwdriver as a chisel. Some people even use a light bulb as a heat source: heat lamp. But what they do doesn't bother me, that's their private world. > > (i.e. used only to exit loops (entering would be too tricky) > > In a high level programming language, *structured* statements should be > used for that purpose. > > <quote> > What we really want is to conceive of our program in > such a way that we rarely even /think/ about *go to* > statements, because the real need for them hardly ever > arises. The language in which we express our ideas has > a strong influence on our thought processes. Therefore, > Dijkstra [23] asks for more new language features -- > structures which encourage clear thinking -- in order > to avoid the *go to*'s temptations toward complications. > <unquote> > [Knuth, Donald E.: Structured Programming with go to Statements. > Computing Surveys, Vol. 6, No. 4, December 1974, pp. 261-301] > > This was written in the 70's of the last century. Now we have modern > languages such as Euphoria. Oh goodie, lets go by 1970's thinks,, and not improve on them. I am so not a fan of Dijkstra and Knuth. Most Ai coders i have read have it wrong too, as the recent slow lingering death of Cyc finally proves. Doug Lenat is 1970's vintage. Thirty years, many $millions, and people-decades later, it has stalled and gone open source. Like all of Lenat's other projects. The theories of mind and psyche are much more advanced since the 70's, see, no more fridged moms causing Asperger's syndrome. Puter science has advanced too. Not gaving a goto won't hurt Eu as much,, but denying us the use of it because someone erroniously said it was bad FOR HIM 30 years ago, because he could not follow the program flow in a few bad program designs back then, is not a valid reason. > And now, in our beloved elegant high level modern programming > language, which encourages structured programming, you want to > introduce this unstructured low level statement GOTO. > I simply cannot understand why. There is no need for it. > (Well, maybe so long as there is no enhancement of Euphoria's exit > statement, there will be a little need. But the consequence should be > to enhance the exit statement, not to introduce GOTO.) The plain fact is, all the while-endwhile, repeat-until, case-endcase, break, exit(), resume, and continue can be replaced with goto. That makes it extremely versatile. In some cases it produces more readable code than a list of boolean tests to skip "structured" code. That word "structured" is getting a worse and worse taste in my mouth, when we are bowing to the theory we must be confined in the straitjacket of prettyprinting the source in the text editor. Once we are done processing deep in a nest of loops and boolean tests, and it is time to go on to the next job, the fastest way there is a straight line: goto. > > and not to replace loops or if/switch statements or routines or any of > > the stuff which should be seperated to be made more readable.) > > <snip> > > > I think that all features should be implemeted, > > I disagree. Anything that is not necessary one the one hand, and has > the potential to cause harm one the other hand, should *not* be > implemented. Like hammers, knives, bowling balls, refridgerators, cars, plastics, cell phones, paper cuts on my fingers, wet towels in locker rooms, hot water, those loud jet engines, etc etc.. > > and that the programmer > > should choose one's own style from there. (Of course Rob would never > > agree to that, and I am better at Euphoria than I am with C, so I continue > > to > > write preproc to get around this limitation. > > Well, if you consider the lack of GOTO as a limitation, I can understand > you, of course. For me this is not a limitation. I've been programming > in PowerBASIC for about 10 years, there is GOTO of course. > I simply never needed it. Because you *can* get by without it doesn't mean you made the best choice. I programmed in a language without *any* loops, goto worked nicely. Consider Eu doesn't have a repeat-until loop, you haveto bracket a while- endwhile with a if-then. Or a while-endwhile with an exit. Or no loops and a goto. It's your *choice*, i would like to chose to use a goto in *some* cases. Kat