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: fac41,9a0ff0bffdf63657 X-Google-Attributes: gidfac41,public X-Google-Thread: f43e6,9a0ff0bffdf63657 X-Google-Attributes: gidf43e6,public X-Google-Thread: 103376,4b06f8f15f01a568 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,9a0ff0bffdf63657 X-Google-Attributes: gid1108a1,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: Why C++ is successful Date: 1998/08/16 Message-ID: #1/1 X-Deja-AN: 381664191 References: <902934874.2099.0.nnrp-10.c246a717@news.demon.co.uk> X-Complaints-To: usenet@news.nyu.edu X-Trace: news.nyu.edu 903279074 20368 (None) 128.122.140.58 Organization: New York University Newsgroups: comp.lang.eiffel,comp.object,comp.software-eng,comp.lang.ada Date: 1998-08-16T00:00:00+00:00 List-Id: Patrick said Well, the fact that you had to add that hint suggests something about your code's clarity... :-) How about this: from J := 1 until J >= N loop if D(J) > D(J+1) then Swap (D(J), D(J+1)); J := 1; else J := J + 1; end end First the hint is simply because, although the algorithmic flow of the original is completely clear, it is my experience that when people contort to remove the gotos, they often end up with a non-equivalent algorithm. That says nothing about the clarity of the original, merely the difficulty of removing the goto. The above code is correct, but for my taste not clearer. I don't like having a loop which at the outside looks like a perfectly normal J from 1 .. N - 1 loop, but is not. Here the unusual structure of this loop is buried in an inner assignment, rather than being evident at the top level in my presentation with a goto. But certainly people differ in tastes and perhaps some will prefer the above, but please prefer it because it is clearer to you, NOT, as is the case for so many programmers, simply because the goto is eliminated. There is nothing inherently unclear about a goto, that's the important thing. On the contrary, the semantics of a goto, intepreted in the normal operational manner at which most programmers interpret semantics, is about as simple as it could be. Yes, of course it is possible to abuse the goto and write disgusting code, but the same can be said about any feature in any language.