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!cs.uu.nl!news.stack.nl!aioe.org!.POSTED!not-for-mail From: Emanuel Berg Newsgroups: comp.lang.ada Subject: Re: 4 beginner's questions on the PL Ada Date: Sat, 10 Aug 2013 19:53:41 +0200 Organization: Aioe.org NNTP Server Message-ID: <878v0977q2.fsf@VLAN-3434.student.uu.se> 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> NNTP-Posting-Host: SWN/nubmpQxYKwY7hPy4YA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) X-Notice: Filtered by postfilter v. 0.8.2 Cancel-Lock: sha1:ksgFptmnFzMl7i2jOOuZ4KdAEN4= Xref: news.eternal-september.org comp.lang.ada:16786 Date: 2013-08-10T19:53:41+02:00 List-Id: Mike H writes: >>And isn't that the same way with you? If you were to explain the C >>for loop to another programmer, would you not just write >> >>for (i = 0; i < STOP; i++) { printf("Pretty clear, huh?\n"); } >> > No. Because I would not know the type of the loop control variable > and hence which of a number of different possible loop constructs > would best suit the questioner's needs for that particular > occasion, e.g. > for ... loop; ... end loop; > for ... in reverse ... loop; end ... loop; > while ... loop; ... end loop; > loop ... ; exit when ...; ... end loop; 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. > Please understand that other contributors to this news group > have provided alternative answers to your questions because your > questions have not always been specific enough to get a specific > answer. That's not the point. There are (almost) always many ways to do things. (That typically hasn't to do with the question, anyway, but is the normal case.) The point is, if you talk about programming by being active with *code*, this is a lot better in many, many ways, and worse in maybe one or two ways. Code is not superficial or lazy. Code *is* programming! -- Emanuel Berg - programmer (hire me! CV below) computer projects: http://user.it.uu.se/~embe8573 internet activity: http://home.student.uu.se/embe8573