From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Elaboration order handling (Was: Bug in 'gnatmake')
Date: Fri, 21 Jun 2013 14:27:34 -0700
Date: 2013-06-21T14:27:34-07:00 [thread overview]
Message-ID: <kq2g6j$qhi$1@dont-email.me> (raw)
In-Reply-To: <wccobazuvoz.fsf@shell01.TheWorld.com>
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
next prev parent reply other threads:[~2013-06-21 21:27 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-17 10:57 Range check for type 'Integer' Peter Brooks
2013-06-17 11:23 ` Simon Clubley
2013-06-17 11:54 ` Simon Wright
2013-06-17 12:55 ` Peter Brooks
2013-06-17 13:28 ` Shark8
2013-06-17 13:45 ` Peter Brooks
2013-06-17 21:16 ` Shark8
2013-06-18 10:48 ` Stephen Leake
2013-06-17 12:46 ` Dmitry A. Kazakov
2013-06-17 13:23 ` Bug in 'gnatmake' (Was: Range check for type 'Integer') Jacob Sparre Andersen
2013-06-17 13:32 ` Bug in 'gnatmake' Jacob Sparre Andersen
2013-06-17 16:50 ` Bug in 'gnatmake' (Was: Range check for type 'Integer') Robert A Duff
2013-06-17 19:15 ` Peter Brooks
2013-06-17 21:09 ` Shark8
2013-06-17 21:22 ` Jeffrey Carter
2013-06-18 1:21 ` Peter Brooks
2013-06-18 6:33 ` Jeffrey Carter
2013-06-18 7:29 ` Georg Bauhaus
2013-06-17 18:49 ` Bug in 'gnatmake' Simon Wright
2013-06-18 9:09 ` Elaboration order handling (Was: Bug in 'gnatmake') Jacob Sparre Andersen
2013-06-18 17:09 ` Robert A Duff
2013-06-18 22:52 ` Adam Beneschan
2013-06-19 1:21 ` Jeffrey Carter
2013-06-19 12:38 ` Robert A Duff
2013-06-19 20:43 ` Georg Bauhaus
2013-06-20 0:37 ` Robert A Duff
2013-06-20 19:56 ` Georg Bauhaus
2013-06-19 12:22 ` Robert A Duff
2013-06-19 15:46 ` Adam Beneschan
2013-06-19 16:41 ` Robert A Duff
2013-06-19 20:47 ` Georg Bauhaus
2013-06-19 21:36 ` Adam Beneschan
2013-06-20 0:57 ` Robert A Duff
2013-06-20 1:09 ` Jeffrey Carter
2013-06-20 2:29 ` Adam Beneschan
2013-06-20 6:08 ` Jeffrey Carter
2013-06-20 15:11 ` Robert A Duff
2013-06-21 5:26 ` Jeffrey Carter
2013-06-21 15:48 ` Adam Beneschan
2013-06-21 18:35 ` Jeffrey Carter
2013-06-21 19:10 ` Robert A Duff
2013-06-21 21:27 ` Jeffrey Carter [this message]
2013-06-21 20:43 ` Adam Beneschan
2013-06-21 21:44 ` Jeffrey Carter
2013-06-21 23:47 ` Robert A Duff
2013-06-23 14:43 ` AdaMagica
2013-06-21 18:58 ` null declarative parts (was: Re: Elaboration order handling) Robert A Duff
2013-06-21 20:42 ` null declarative parts Georg Bauhaus
2013-06-20 2:11 ` Elaboration order handling (Was: Bug in 'gnatmake') Adam Beneschan
2013-06-20 14:44 ` Robert A Duff
2013-06-20 11:24 ` G.B.
2013-06-20 15:23 ` Robert A Duff
2013-06-19 21:00 ` Georg Bauhaus
2013-06-19 22:26 ` Randy Brukardt
2013-06-20 0:31 ` Robert A Duff
2013-06-20 21:36 ` Randy Brukardt
2013-06-19 13:07 ` Bill Findlay
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox