comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@acm.nospam.org>
Subject: Re: Another question about controlled types.
Date: Sat, 09 Feb 2008 21:50:02 GMT
Date: 2008-02-09T21:50:02+00:00	[thread overview]
Message-ID: <eeprj.23080$9j6.1361@attbi_s22> (raw)
In-Reply-To: <47ae13b2$0$32493$4d3efbfe@news.sover.net>

Peter C. Chapin wrote:
> I'm using GNAT GPL 2007. I understand that Ada 2005 allows one to return 
> limited types from functions. Consider the following package 
> specification and body:
> 
> package Check is
>    type Some_Type is limited private;
>    function Make(I : Integer) return Some_Type;
> private
>    type Some_Type is
>       record
>          Component : Integer;
>       end record;
> end Check;

The full view is not limited.

> with Ada.Finalization;
> 
> package Check is
>    type Some_Type is limited private;
>    function Make(I : Integer) return Some_Type;
> private
>    type Some_Type is new Ada.Finalization.Limited_Controlled with
>       record
>          Component : Integer;
>       end record;
> end Check;

Here the full view is limited. That is the difference.

To return a limited value, you now need to either return an aggregate or use the 
extended return statement:

return Some_Type'(Ada.Finalization.Limited_Controlled with Component => I);

or

return Result : Some_Type do
    Result.Component := I;
end return;

See ARM 6.5.

-- 
Jeff Carter
"I soiled my armor, I was so scared."
Monty Python & the Holy Grail
71



  reply	other threads:[~2008-02-09 21:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-09 20:57 Another question about controlled types Peter C. Chapin
2008-02-09 21:50 ` Jeffrey R. Carter [this message]
2008-02-09 23:41   ` Peter C. Chapin
replies disabled

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