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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!xmission!news.glorb.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 10 Aug 2013 14:50:30 -0500 From: Dennis Lee Bieber Newsgroups: comp.lang.ada Subject: Re: 4 beginner's questions on the PL Ada Date: Sat, 10 Aug 2013 15:50:35 -0400 Organization: IISS Elusive Unicorn Message-ID: References: <87ob96ajv6.fsf@VLAN-3434.student.uu.se> <03ea570b-e45f-4694-ab9b-3413c4770379@googlegroups.com> <878v0aee8i.fsf@VLAN-3434.student.uu.se> <87txiycxx9.fsf@VLAN-3434.student.uu.se> <2531ecb1-4ac0-404a-8229-3110d4268374@googlegroups.com> <87mwoqbao2.fsf@VLAN-3434.student.uu.se> <878v0977q2.fsf@VLAN-3434.student.uu.se> X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 108.68.178.245 X-Trace: sv3-syL/Dum9O2Jer+cpbNSA94g9KhQOUqGJMZNpmWY8R8Bv+K9G0Q566qCzBOFGlV7WT/XEyBm29QqnQfA!lPnNmtSsUxS811OYpLydNoCTv22Y3g+Oy2SmvKMx0VqsbPIwJBa742FsJObeIbFqUsBxHwkFjbau!CiKFNsAGRZ+LmHWym7qrbSeJ5QxM X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 4330 Xref: news.eternal-september.org comp.lang.ada:16790 Date: 2013-08-10T15:50:35-04:00 List-Id: On Sat, 10 Aug 2013 19:53:41 +0200, Emanuel Berg declaimed the following: >That's Ada, not C. The for loop in C is the for loop in C, and the >best way to explain it is to say it is excellent for cases where >the increment variable is usable inside the loop, as in iterating >an array, *or* when it is known beforehand how many times >something should be done. Then you post the syntax (the code, the >example), and - perhaps - mention that 'continue' and 'break' can >be used to circumvent execution flow. This is the way I would have >done it. If you would have queried further on the context, and >dumping URLs to documentation, that's your call. > And that description is rather meaningless to me... C-style for loops pretty much mandate breaking apart into parts as they ARE so generic. for ( [initialization part]; [repeat condition part]; [{iteration setup part]) { [action part] }; After all, each part is optional! for (; [repeat condition part];) { ... } is identical to a while loop while ([repeat condition part]) { ... } Heck: [initialization part] while ([repeat condition part]) { ... [iteration setup part] } is a full description of the C-style for loop (especially in older C where you have to predeclare any "loop variables" used in the initialization). In Ada, the basic loop, from which all others are built, is: loop .... end loop; >From that one can define loops that iterate over a known/consecutive range of values for counter in first..last loop .... end loop; Or a loop that has variable number of repeats based upon some condition determined within the loop itself while condition loop .... end loop; Or even loops that need to repeat some setup actions for each iteration which affects the exit criteria loop pre-condition action exit when not condition; post-condition action end loop; which would require duplicated code in other languages (or misleading loop structures) pre-condition action while (condition) { post-condition action pre-condition action /* to set up next iteration */ } or while (1) /* superfluous "condition check", it never exits loop */ { pre-condition action if (not condition) break; post-condition action } or for (pre-condition action; condition; pre-condition action) { post-condition action } >Code is not superficial or lazy. Code *is* programming! Code is IMPLEMENTATION... Programming takes place outside of any language; one maps algorithms into the language specific syntax/semantics to implement the algorithm (program/recipe). -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/