From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11390f,4c42ac518eba0bbe X-Google-Attributes: gid11390f,public X-Google-Thread: 1014db,4c42ac518eba0bbe X-Google-Attributes: gid1014db,public X-Google-Thread: 103376,4c42ac518eba0bbe X-Google-Attributes: gid103376,public X-Google-Thread: 109fba,4c42ac518eba0bbe X-Google-Attributes: gid109fba,public From: kaz@helios.crest.nt.com (Kaz Kylheku) Subject: Re: Programming language vote - results Date: 1997/11/25 Message-ID: <65gaoj$f8u$1@helios.crest.nt.com>#1/1 X-Deja-AN: 292744852 References: <343fbb5a.0@news.iprolink.ch> <3470EF6E.F74@lysator.liu.se> <879863453snz@genesis.demon.co.uk> Organization: A poorly-installed InterNetNews site Newsgroups: comp.lang.ada,comp.lang.apl,comp.lang.c,comp.lang.c++ Date: 1997-11-25T00:00:00+00:00 List-Id: In article , Martin M Dowie wrote: >In article <879863453snz@genesis.demon.co.uk>, Lawrence Kirby > writes >>In article <3470EF6E.F74@lysator.liu.se> >> ingemar@lysator.liu.se "Ingemar Ragnemalm" writes: >> >>... >>Perhaps you could give an example of something that is used more than once >>in a blue moon? C supports goto. It is rarely used in practice but there >>are some situations where it is simply the best approach. > >i've heard many people use this "where it is simply the best approach" >'reason' - care to given an example? and please don't say to stop doing >one thing quickly in order to do another - that is simply indicative of >a poorly analysed and designed system. The ``to goto or not goto'' debate has been settled decades ago. Both sides were wrong. :) Whether or not it is appropriate to use a goto depends on the programming language---namely, what control structures the language supports. If the language only supports GOTO-like structures, then your choice is made for you. In other cases it's not that clear. Suppose that you want to break out of some deeply nested block statement. If your language supports a ``break N'' statement, to break out of N nesting levels, or a ``break '' where is the name of the enclosing block from which you want to jump out, then you will use the break. If you don't have it, you either use a simple goto, or an extra variable plus a number of tests at each level. It must be remembered that goto is the most general and powerful control mechanism and is an important ``escape hatch''. Today, goto no longer calls for fear and disdain, because it isn't the monster that it was thought to be in the 60's. How recently have you come across a program that was rotten due to the abuse of goto? Is this really a valid concern? >Ada also supports a 'goto' statement (though with much tighter controls) >but the only valid reason i've ever come across for using it is for >automated code generators. That's an important application, given that some CASE tools generate code. In some cases, you could probably trust a goto-ridden automatically generated code more readily than hand-written structured code.