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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,81bb2ce65a3240c3 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.232.42 with SMTP id tl10mr4107785pbc.7.1335396060296; Wed, 25 Apr 2012 16:21:00 -0700 (PDT) Path: r9ni98541pbh.0!nntp.google.com!news2.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: What would you like in Ada202X? Date: Wed, 25 Apr 2012 16:13:56 -0700 (PDT) Organization: http://groups.google.com Message-ID: <18684452.720.1335395636464.JavaMail.geo-discussion-forums@yncc41> References: <3637793.35.1335340026327.JavaMail.geo-discussion-forums@ynfi5> <31103380.3735.1335377235157.JavaMail.geo-discussion-forums@vbuo17> <26317529.742.1335381313996.JavaMail.geo-discussion-forums@ynje10> <17572718.3572.1335384748259.JavaMail.geo-discussion-forums@vbbfk16> <30695328.1199.1335386401806.JavaMail.geo-discussion-forums@yndm3> <6600577.869.1335391548297.JavaMail.geo-discussion-forums@vbdx11> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 X-Trace: posting.google.com 1335396060 8676 127.0.0.1 (25 Apr 2012 23:21:00 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 25 Apr 2012 23:21:00 +0000 (UTC) In-Reply-To: <6600577.869.1335391548297.JavaMail.geo-discussion-forums@vbdx11> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-04-25T16:13:56-07:00 List-Id: On Wednesday, April 25, 2012 3:05:48 PM UTC-7, okel...@users.sourceforge.ne= t wrote: > On Wednesday, April 25, 2012 10:40:01 PM UTC+2, Adam Beneschan wrote: > > > >=20 > > [...] I've tried to argue here that using "continue" is worse for > > readability than using a "goto" in this case-- [...] >=20 > In which case? If you write this: loop -- several hundred lines of code Do_This_Action; end loop; If I'm looking at the code, and I look at just the bottom part, it's obviou= s that Do_This_Action will always be called before the loop loops back. If= I'm maintaining the code, and I want to add something else that will alway= s be called before the loop cycles back, I can add a statement after Do_Thi= s_Action, and I know it will work. If "continue" is added to the language, this inference is no longer true. = Now it raises the possibility that I can add a statement after Do_This_Acti= on, expecting it will always be executed at the end of the loop, but that e= xpectation will be wrong if somewhere, in the hundreds of lines of code, yo= u've stuck a "continue" statement. So that increases the probability of er= ror. =20 If you've used a goto, however, the end of the loop will look like: loop -- several hundred lines of code Do_This_Action; <> null; end loop; Now I'm aware that if I want to add something that will always be executed = in the loop, I need to be careful to make sure I add it at the right place = (either after or before the Continue_Here label), and I'll need to study th= e logic a bit more to make sure I get it right. But the label alerts me to= that need. So it's less error-prone. This isn't just a theoretical argum= ent; it's based on what's actually happened, in my experience. Of course, if there are just a few lines of code, it's easier to figure out= what the code is doing and easier to modify it correctly. And I think tha= t in your original example, where you said there would be a couple hundred = statements in your loop, that's the real problem. If you have that much co= de in your loop, chances are you should be putting a lot of it into a subro= utine(s). But if your loop is smaller, there's less need to have a "contin= ue" or "goto" statement anyway. I suppose this is a YMMV matter; maybe other programmers wouldn't have as m= uch trouble reading and maintaining this kind of code. But since it's defi= nitely something that caused me problems, I wanted to make sure I mentioned= it. And I'm still skeptical of any coding standard that bans "goto" but n= ot "continue"; I'd suspect that the person who came up with that standard d= id so because they heard somewhere that goto was evil, demonic, and fatteni= ng, not for any rational reason. -- Adam