From: Georg Bauhaus <sb463ba@l1-hrz.uni-duisburg.de>
Subject: Re: [Q] non-limited record and "self-pointer"
Date: Mon, 9 Feb 2004 15:45:59 +0000 (UTC)
Date: 2004-02-09T15:45:59+00:00 [thread overview]
Message-ID: <c089vn$ir4$1@a1-hrz.uni-duisburg.de> (raw)
In-Reply-To: mailman.8.1076331043.295.comp.lang.ada@ada-france.org
Stephen Leake <stephen_leake@acm.org> wrote:
: Georg Bauhaus <sb463ba@l1-hrz.uni-duisburg.de> writes:
:
:> Stephen Leake <stephen_leake@acm.org> wrote:
:> : I'm not clear what you are asking.
:>
:> I'm puzzled too by the compiler's silence, because AFAIK a record cannot
:> silently become limited?
:
: Post a complete, compilable example, and I'll take another look at it.
There it is, ObjectAda 7.2.2 does not complain either.
with sets;
package some_sets is new sets(Integer);
with some_sets; use some_sets;
procedure simple_test is
s1, s2: Read_Only_Set;
s: Set;
p: Set_Ptr;
begin
s1 := s2;
p := value_in_place(s);
end simple_test;
with Charles.Sets.Sorted.Unbounded;
generic
type Element is private;
with function "<"(L, R: Element) return Boolean is <>;
with function "="(L, R: Element) return Boolean is <>;
--with function wide_image(e: Element) return Wide_String is <>;
package Sets is
type Read_Only_Set is tagged private;
-- Modifiable Sets
type Set is new Read_Only_Set with private;
type Set_Ptr is access all Read_Only_Set'class;
function value_in_place(container: Set) return Set_Ptr;
-- a pointer to container (avoids copying)
private
package Implementation is
new Charles.Sets.Sorted.Unbounded(Element);
type Read_Only_Set is tagged
record
container: Implementation.Container_Type;
self: Set_Ptr := Read_Only_Set'unchecked_access;
-- used in value_in_place
end record;
type Set is new Read_Only_Set with record
frozen: Boolean := true;
end record;
end Sets;
package body Sets is
use Implementation;
-- ----------------
-- value_in_place
-- ----------------
-- every object of type Set points to itself
function value_in_place(container: Set) return Set_Ptr is
-- cont: aliased Set;
-- for cont'address use container'address;
-- cannot overlay controlled
-- package set_ptrs is new System.Address_to_Access_conversions(Set);
begin
return container.self;
end value_in_place;
end Sets;
next prev parent reply other threads:[~2004-02-09 15:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-08 21:26 [Q] non-limited record and "self-pointer" Georg Bauhaus
2004-02-09 0:58 ` Stephen Leake
2004-02-09 2:56 ` Georg Bauhaus
2004-02-09 12:50 ` Stephen Leake
2004-02-09 15:45 ` Georg Bauhaus [this message]
2004-02-10 1:35 ` Dan Eilers
2004-02-10 2:30 ` Stephen Leake
2004-02-10 7:20 ` Robert I. Eachus
2004-02-11 18:41 ` Georg Bauhaus
2004-02-11 22:05 ` Randy Brukardt
2004-02-12 0:21 ` Robert I. Eachus
2004-02-12 20:44 ` Georg Bauhaus
2004-02-14 0:25 ` Robert I. Eachus
2004-02-14 4:09 ` Robert I. Eachus
2004-02-14 0:24 ` Adam Beneschan
2004-02-14 6:04 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox