comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@on2.com (Matthew Heaney)
Subject: Re: controlled initialization
Date: 16 Dec 2002 15:26:02 -0800
Date: 2002-12-16T23:26:03+00:00	[thread overview]
Message-ID: <1ec946d1.0212161526.7eb81067@posting.google.com> (raw)
In-Reply-To: 1040049195.294541@master.nyc.kbcfp.com

Hyman Rosen <hyrosen@mail.com> wrote in message news:<1040049195.294541@master.nyc.kbcfp.com>...
> 
> Ooh, ooh, I know, I know! I remember this from a thread
> a while ago. Init isn't called for objects that are
> initialized by aggregates. A rationale is that since
> you are supplying all the fields in the aggregate, you
> can just do whatever setup the Init proccedure would
> have done.

The real problem is when you're declaring a deferred constant, e.g.

package P is

   type T is private;

   O : constant T;

private

   type T is new Controlled with null record;

   procedure Initialize (O : in out T);

   O : constant T := (Controlled with null record);

end P;

The problem is that the body of P hasn't elaborated at the moment when
object O is elaborated.  Were Initialize to be called at the point of
elaboration of O, then Program_Error would be raised because the body
of Initialize hasn't been elaborated yet.

So for aggregate initialization, Initialize doesn't get called, and
all initialization is done in-place.



  parent reply	other threads:[~2002-12-16 23:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-16  7:04 controlled initialization Maxim Reznik
2002-12-16 14:33 ` Hyman Rosen
2002-12-16 15:06   ` Robert A Duff
2002-12-16 23:26   ` Matthew Heaney [this message]
2002-12-17  1:50     ` Hyman Rosen
2002-12-17  2:00       ` Bill Findlay
2002-12-17  7:55       ` Simon Wright
2002-12-17  6:59   ` Maxim Reznik
2002-12-16 23:31 ` Stephen Leake
2002-12-16 23:31 ` Matthew Heaney
  -- strict thread matches above, loose matches on Subject: below --
2002-12-17  6:20 Grein, Christoph
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox