comp.lang.ada
 help / color / mirror / Atom feed
From: Hyman Rosen <hyrosen@mail.com>
Subject: Re: controlled initialization
Date: Mon, 16 Dec 2002 09:33:15 -0500
Date: 2002-12-16T09:33:15-05:00	[thread overview]
Message-ID: <1040049195.294541@master.nyc.kbcfp.com> (raw)
In-Reply-To: <3DFD7B15.9050800@mbank.com.ua>

Maxim Reznik wrote:

> I expected statement
>  return Statement'(Ada.Finalization.Controlled with C => 0);
> created object of type Statement,
> then Initialyze procedure would be called for it and
> Put_Line printed "Init".
>
> But when I compile program with GNAT 3.15p for Linux
> it doesn't happen.
>
> May be it's bug of GNAT?


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. Of course, this doesn't work if the Init
procedure has side effects. In that case, I think the
solution is to make the type limited, so that users can't
initialize with aggregates at all, and you can call the
Init procedure "by hand" in the private code.




  reply	other threads:[~2002-12-16 14:33 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 [this message]
2002-12-16 15:06   ` Robert A Duff
2002-12-16 23:26   ` Matthew Heaney
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