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!mx05.eternal-september.org!feeder.eternal-september.org!xmission!newsswitch.lcs.mit.edu!nntp.TheWorld.com!.POSTED!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: null declarative parts (was: Re: Elaboration order handling) Date: Fri, 21 Jun 2013 14:58:49 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <7f33982d-3bcf-452e-a3b3-3a0a28505ff1@x20g2000vbe.googlegroups.com> <87r4g0g9c0.fsf@adaheads.sparre-andersen.dk> <87ip1bg4z2.fsf_-_@adaheads.sparre-andersen.dk> <53d0b070-a03b-43d0-a560-68dd3a8bebf5@googlegroups.com> <51c218df$0$6623$9b4e6d93@newsspool2.arcor-online.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1371841129 3206 192.74.137.71 (21 Jun 2013 18:58:49 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 21 Jun 2013 18:58:49 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:3eRlSNnJwheFE8x6vOhbUcackhc= Xref: news.eternal-september.org comp.lang.ada:15879 Date: 2013-06-21T14:58:49-04:00 List-Id: Jeffrey Carter writes: > On 06/20/2013 08:11 AM, Robert A Duff wrote: >> >> P.S. I don't like your convention of putting "-- null;" in empty >> declarative parts! Comments should impart useful information, >> and empty declarative parts are nothing special, and anyway, >> I can see it's empty without a comment. > > The I guess you'd prefer > > while Function_With_Side_Effects loop > end loop; A loop with no statements is something special and rare; the reader's attention should be drawn to it. So I don't mind putting "null;". Empty declarative parts are not special, and are common. I wouldn't mind if Ada didn't require "null;" in that loop, but then I'd leave a blank line to make it stand out: while Function_With_Side_Effects loop end loop; Or I'd put a comment: while Function_With_Side_Effects loop -- Nothing to do here. end loop; Or maybe even a comment explaining why there's nothing to do. I'm not 100% opposed to functions with side effects, but they should be rare, and the above loop code is therefore dubious. So it should stand out. Certain languages like C and Pascal have an error-prone syntax: while (...); ^ There's an empty loop body there, but you can't see it! There are (at least) two ways to fix that: (1) Require null statements to be explicit. (2) Require "end loop", "end if", and so on. Ada does both, which is a belts and suspenders solution. I think (2) is a great idea. As for (1), I can take it or leave it -- shrug. On a related subject, I would eliminate the "begin" in the middle of a procedure body, and allow mixing of declarations and statements without using block statements. I would ALLOW block statements, but their syntax would be something like: begin ... -- statements and declarations end; Since declarations are executable in Ada, it makes no sense to have a strong separation between the declarations and the statements of a procedure body (and similar constructs). That syntax is a vestige that was inherited from Pascal for no good reason. > to the Ada requirement that you have to put a null statement in there? I > like the idea that something that's empty has to have something special > in it to show that it's deliberately empty, and think it should apply to > declarative parts, as well. I don't expect to convince you. It's largely a matter of taste. I tried to explain the reasons for my "taste" above. You probably like the syntax "(null record)" for an empty aggregate; I would prefer "[]" (with square brackets). I might leave a blank, to emphasize its emptiness -- "[ ]" -- but that's as far as I'd go. - Bob