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!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: Elaboration order handling (Was: Bug in 'gnatmake') Date: Fri, 21 Jun 2013 14:27:34 -0700 Organization: Also freenews.netfront.net; news.tornevall.net 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> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 21 Jun 2013 21:22:29 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="ea9e222491b6e4ac16c72e6c1b727e42"; logging-data="27186"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+wtUWcQ1mKcxsuG+dzguZAyJHiiJQYgcM=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: Cancel-Lock: sha1:nNgmEwh7vAx+P73BBN1wsU9hOp0= Xref: news.eternal-september.org comp.lang.ada:15883 Date: 2013-06-21T14:27:34-07:00 List-Id: On 06/21/2013 12:10 PM, Robert A Duff wrote: > > Interesting. You are very close to agreeing with me that statements and > declarations are more-or-less the same thing (syntactically), and > wherever one is allowed, so should the other. What's wrong with > statements in a package spec (or body decl part)? If you allow "null;" > in a declarative part, then why not allow an assignment statement, or a > procedure call? And if you do that, there's no point at all to the > "begin" that appears in the middle of a procedure body. I've seen code in languages that allow mixing of declarations and executable statements, and I didn't like it. Maybe this is because I'm used to Ada (and Pascal before it), but I found it difficult to find a declaration when I needed to. (Tools can help, but are not always available; since I don't use these languages, I wasn't using tools when I looked at them.) > Once in a while, I want to initialize an object using statements, > because the "X: T := ...;" syntax doesn't work for some reason. > > package body P is > X : ...; > > package Dummy is end; > package body Dummy is > begin > for I in ... loop > X(I) := ...; > end loop; > end Dummy; > ... -- 1000 more lines of code > > That extra Dummy package doesn't aid readability. The other choice, > moving the initialization way down into the "begin...end P;" part > is also bad, because the initialization is far away from the > declaration, and there's lots of opportunity to use uninitialized > variables in between. The "X : T := ...;" syntax almost always works if the initialization expression is a function call: package body P is function Initialize_X return T is ... X : T := Initialize_X; I built some default-initialized types with fairly complex initialization in Ada-83 using such functions, which is why I didn't think Ada-95 really needed user-defined initialization. Finalization was another matter. -- Jeff Carter "Sheriff murdered, crops burned, stores looted, people stampeded, and cattle raped." Blazing Saddles 35