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, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,14f7200925acb579 X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: No Go To's Forever! Date: 2000/03/23 Message-ID: <8bbsc6$aes$1@nnrp1.deja.com>#1/1 X-Deja-AN: 601103702 References: <8baqlu$3qp$1@nnrp1.deja.com> X-Http-Proxy: 1.0 x25.deja.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Thu Mar 23 01:35:03 2000 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.61 [en] (OS/2; I) Date: 2000-03-23T00:00:00+00:00 List-Id: In article , tmoran@bix.com wrote: > I personally find this clearer, even if a tad longer: > loop > J := D'first; > while J < D'last and then D(J) >= D(J+1) loop > J := J+1; > end loop; > exit when J >= D'last; > Swap (D (J), D (J + 1)); > end loop; Well that's a different algorithm. It tests J against D'Last twice as often as my formulation. Yes, perhaps a clever compiler will be able to rescue this, but algorithmically, this simply is not equivalent. Actually most compilers won't fix this, so you will find that your version actually does run noticably slower that the original. Yes, code duplication is one way of getting around the goto here, but again you are changing the algorithm. Please tackle the harder problem: Take the algorithm *I* presented, and remove the goto without changing the sequence of computations, and see if that result is clearer. P.S. I don't find your changed algorithm clearer, precisely because of the peculiar duplicated check. Sent via Deja.com http://www.deja.com/ Before you buy.