comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Private constant of tagged limited controlled type
Date: Fri, 21 Oct 2011 23:29:19 -0700
Date: 2011-10-21T23:29:19-07:00	[thread overview]
Message-ID: <j7trtm$q5t$1@tornado.tornevall.net> (raw)
In-Reply-To: <da20b9c1-54ff-4f1b-802b-9ddd5b2a84ff@u9g2000vby.googlegroups.com>

On 10/21/2011 11:14 PM, Malaise wrote:
> The following complains that "initialization of limited object
> requires aggregate or function call":

Right.

> with Ada.Finalization;
> package Pack is
>    type T is tagged limited private;
>    C : constant T;
> private
>    type T is new Ada.Finalization.Limited_Controlled with record
>      I : Integer := 0;
>    end record;
>    V : T;
>    C : constant T := V;
> end Pack;
> Aggregate seems impossible because Limited_Controlled is abstract and
> anyway T is very complex in fact.

I suggest you read ARM 4.3.1 and 4.3.2. You can write an aggregate of the form

(Ada.Finalization.Limited_Controlled with others => <>)

> A function (returning tagged type) has to be visible and anyway cannot
> return V (in Ada 2005).

This is an unusual claim. The extended return statement was introduced 
specifically for returning limited types from a function. You ought to read ARM 
6.5. You could write

return X : T;

to return a value of T with all components set to their default values.

-- 
Jeff Carter
"We use a large, vibrating egg."
Annie Hall
44



  reply	other threads:[~2011-10-22  6:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-22  6:14 Private constant of tagged limited controlled type Malaise
2011-10-22  6:29 ` Jeffrey Carter [this message]
2011-10-22 15:16   ` Robert A Duff
2011-10-23  6:18 ` Malaise
replies disabled

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