comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: controlled initialization
Date: 17 Dec 2002 07:55:35 +0000
Date: 2002-12-17T07:55:35+00:00	[thread overview]
Message-ID: <x7vof7lhyfc.fsf@smaug.pushface.org> (raw)
In-Reply-To: DpvL9.30910$4W1.11730@nwrddc02.gnilink.net

Hyman Rosen <hyrosen@mail.com> writes:

> Interesting. So (remembering that I don't know Ada) the following
> would be illegal as well? If it is, is there a way to do what the
> code obviously intends? Do I understand the issue correctly, that
> is that MakeT could use O?
> 
> package P is
>    type T is private;
>    O : constant T;
> private
>    type T is new Controlled with null record;
>    function MakeT return T;
>    O : constant T := MakeT;
> end P;

One possibility is to make O a function (inlined if you need to).

A related difficulty is where T is indefinite: from the under-work
Booch Components,

1   type Unconstrained_Map
2     (Number_Of_Buckets : Positive) is new Abstract_Map with private;
3
4   subtype Map is Unconstrained_Map (Number_Of_Buckets => Buckets);
5
6   function Null_Container return Unconstrained_Map;
7   --  Note, this function has to be provided but the object returned
8   --  is in fact a Map (ie, it is constrained).

Buckets in line 4 is a generic parameter, retained for consistency
with previous releases, specifying the default number of hash
buckets. Null_Container at line 6 is required because it's abstract in
the parent. Still, folk relying on Null_Container can use it with the
previous semantics.



  parent reply	other threads:[~2002-12-17  7:55 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
2002-12-17  1:50     ` Hyman Rosen
2002-12-17  2:00       ` Bill Findlay
2002-12-17  7:55       ` Simon Wright [this message]
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